parent
55d8e3dbc0
commit
3d81e37405
@ -0,0 +1,3 @@
|
||||
// comments can make code readable.
|
||||
// Welcome to 30DaysOfJavaScript
|
||||
/* comments can make code readable, easy to use and informative */
|
||||
@ -0,0 +1,60 @@
|
||||
// Create a variable.js file and declare variables and assign string, boolean, undefined and null data types
|
||||
|
||||
let fullName = "John Doe";
|
||||
let ageNow = 50;
|
||||
let isDivorced = true;
|
||||
let car = undefined;
|
||||
let kids = null;
|
||||
|
||||
console.log(
|
||||
typeof "fullName",
|
||||
typeof ageNow,
|
||||
typeof isDivorced,
|
||||
typeof car,
|
||||
typeof kids
|
||||
);
|
||||
|
||||
let fruit = null;
|
||||
let vegetable = null;
|
||||
let fish = null;
|
||||
let meat = null;
|
||||
|
||||
console.log(fruit, vegetable, fish, meat);
|
||||
|
||||
let carModel = "Toyota";
|
||||
let yearMade = 2019;
|
||||
let price = 100000;
|
||||
let color = "red";
|
||||
|
||||
console.log(carModel, yearMade, price, color);
|
||||
|
||||
let nameFirst = "Daniel";
|
||||
let nameLast = "Fernandez";
|
||||
let countryOfOrigin = "Spain";
|
||||
let currentAge = 35;
|
||||
let maritalStatus = "single";
|
||||
|
||||
let name1 = "John",
|
||||
name2 = "Doe",
|
||||
ethnicity = "Indian",
|
||||
personAge = 50,
|
||||
marriageStatus = "married";
|
||||
|
||||
console.log(nameFirst, nameLast, countryOfOrigin, currentAge, maritalStatus);
|
||||
console.log(name1, name2, ethnicity, personAge, marriageStatus);
|
||||
|
||||
// Array creation
|
||||
let details = [
|
||||
(nameFirst = "John"),
|
||||
(nameLast = "Doe"),
|
||||
(countryOfOrigin = "USA"),
|
||||
(currentAge = 50),
|
||||
(maritalStatus = "single"),
|
||||
];
|
||||
|
||||
console.log(details);
|
||||
|
||||
const myAge = 35;
|
||||
const yourAge = 50;
|
||||
|
||||
console.log(`I am ${myAge} years old. and you are ${yourAge} years old.`);
|
||||
@ -0,0 +1 @@
|
||||
console.log("Hello World!");
|
||||
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>30 Days of Javascript</title>
|
||||
<link rel="stylesheet" href="./style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<button onclick="alert('Welcome to 30 days of JS!');">Click Me</button>
|
||||
<script src="helloworld.js"></script>
|
||||
<script src="introduction.js"></script>
|
||||
<script src="day-01_exercises.js"></script>
|
||||
<script src="day-01_variable.js"></script>
|
||||
<script src="main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,7 @@
|
||||
console.log("welcome to 30 Days of JS");
|
||||
// Data types check:
|
||||
console.log(typeof "Asabeneh"); // string
|
||||
console.log(typeof 5); // number
|
||||
console.log(typeof true); // boolean
|
||||
console.log(typeof null); // object type
|
||||
console.log(typeof undefined); // undefined
|
||||
@ -0,0 +1,24 @@
|
||||
let firstName = "Asabeneh"; // first name of a person
|
||||
let lastName = "Yetayeh"; // last name of a person
|
||||
let country = "Finland"; // country
|
||||
let city = "Helsinki"; // capital city
|
||||
let age = 100; // age in years
|
||||
let isMarried = true;
|
||||
|
||||
console.log(firstName, lastName, country, city, age, isMarried);
|
||||
|
||||
// Declaring variables with number values
|
||||
const gravity = 9.81; // earth gravity in m/s2
|
||||
const boilingPoint = 100; // water boiling point, temperature in °C
|
||||
const PI = 3.14; // geometrical constant
|
||||
console.log(age, gravity, boilingPoint, PI);
|
||||
|
||||
// Returns 9.81 100 3.14
|
||||
|
||||
// Variables can also be declaring in one line separated by comma, however I recommend to use a seperate line to make code more readble
|
||||
let name = "Asabeneh",
|
||||
job = "teacher",
|
||||
live = "Finland";
|
||||
console.log(name, job, live);
|
||||
|
||||
// Returns Asabeneh teacher Finland
|
||||
@ -0,0 +1,7 @@
|
||||
body {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: grey;
|
||||
height: 500px;
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Day 2</title>
|
||||
<link rel="stylesheet" href="./style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<button onclick="alert('Day 2 Challenges');">Click Me</button>
|
||||
<script src="main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,56 @@
|
||||
console.log("Day 2: Data types");
|
||||
console.log("Exercise: Level 1");
|
||||
|
||||
let challenge = " 30 Days Of Javascript ";
|
||||
console.log(challenge);
|
||||
console.log(challenge.length);
|
||||
console.log(challenge.toUpperCase());
|
||||
console.log(challenge.toLowerCase());
|
||||
console.log(challenge.slice(0, 2));
|
||||
console.log(challenge.slice(3, 21));
|
||||
console.log(challenge.includes("script"));
|
||||
console.log(challenge.split());
|
||||
console.log(challenge.split(" "));
|
||||
|
||||
let companies = "Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon";
|
||||
console.log(companies.split(","));
|
||||
|
||||
console.log(challenge.replace("Javascript", "Python"));
|
||||
console.log(challenge.charAt(15));
|
||||
console.log(challenge.indexOf("a"));
|
||||
console.log(challenge.lastIndexOf("a"));
|
||||
|
||||
let sentenceA =
|
||||
"You cannot end a sentence with because because because is a conjunction";
|
||||
|
||||
console.log(sentenceA.indexOf("because"));
|
||||
console.log(sentenceA.lastIndexOf("because"));
|
||||
console.log(sentenceA.search("because"));
|
||||
|
||||
console.log(challenge.trim());
|
||||
console.log(challenge.startsWith("30"));
|
||||
console.log(challenge.endsWith("Javascript"));
|
||||
console.log(challenge.match("a"));
|
||||
console.log(challenge.match(/a/gi)); // g = global, i = case insensitive => matches all a's in the string regardless of case.
|
||||
console.log("30 Days of".concat(" Javascript"));
|
||||
console.log(challenge.repeat(2));
|
||||
|
||||
console.log("Exercise: Level 2");
|
||||
|
||||
let sentenceB =
|
||||
"There is no exercise better for the heart than reaching down and lifting people up.";
|
||||
|
||||
console.log(sentenceB);
|
||||
|
||||
let sentenceC =
|
||||
"Love is not patronizing and charity isn't about pity, it is about love. Charity and love are the same -- with charity you give love, so don't just give money but reach out your hand instead.";
|
||||
|
||||
console.log(sentenceC);
|
||||
|
||||
console.log(typeof "10" == 10);
|
||||
console.log(parseInt("10") == 10);
|
||||
console.log(parseFloat("9.8" === 10));
|
||||
console.log(Math.round(parseFloat("9.8")) === 10);
|
||||
|
||||
let sentenceD = "python jargon";
|
||||
console.log(sentenceD.indexOf("on") !== -1);
|
||||
@ -0,0 +1,7 @@
|
||||
body {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: grey;
|
||||
height: 500px;
|
||||
}
|
||||
Loading…
Reference in new issue