Skip to content

Commit dc332b7

Browse files
committed
some examples added
1 parent b164dae commit dc332b7

16 files changed

+533
-456
lines changed

00-introduction.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
console.log ('Welcome JavaScript');
2-
console.log ('Congratulations! You wrote you first JavaScript code.');
1+
console.log('Welcome toJavaScript');
2+
console.log('Congratulations! You wrote you first JavaScript code.');
3+
console.log('Welcome to JavaScript for Everyone');

01-variables.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
// Declaring different variables of different data types
2-
let firstName = "Asabeneh";
3-
let lastName = "Yetayeh";
4-
let location = "Helsinki";
5-
const country = "Finland";
2+
let firstName = 'Asabeneh';
3+
let lastName = 'Yetayeh';
4+
let location = 'Helsinki';
5+
let country = 'Finland';
6+
let city = 'Helsinki';
67
let age = 100;
78
let isMarried = true;
89
const gravity = 9.81;
910
const boilingPoint = 100;
10-
const PI = 3.14;
11+
const PI = 3.14; // can can be accessed like this too: Math.PI
1112
console.log(firstName, lastName, location, country, age, gravity, PI);
1213

1314
// Variables can also be declaring in one line separated by comma
14-
let name = "Asabeneh",
15-
job = "Teacher",
16-
live = "Finland";
17-
console.log(name, job, live)
18-
15+
let name = 'Asabeneh',
16+
job = 'Teacher',
17+
live = 'Finland';
18+
console.log(name, job, live);
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// Declaring different variables of different data types
2-
let firstName = "Asabeneh";
3-
let lastName = "Yetayeh";
4-
let fullName = firstName + " " + lastName; // concatination, merging to string together.
2+
let firstName = 'Asabeneh';
3+
let lastName = 'Yetayeh';
4+
let fullName = firstName + ' ' + lastName; // concatination, merging to string together.
55
console.log(fullName);
66

7-
8-
let personInfoOne = fullName + ".I am " + age + ". I live in " + country; // ES5
7+
let personInfoOne = fullName + '.I am ' + age + '. I live in ' + country; // ES5
98
let personInfoTwo = `I am ${fullName}.I am ${age}. I live in ${country}`; //ES6 - String interpolation method
109
console.log(personInfoOne);
1110
console.log(personInfoTwo);

04-string_interpolation.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
let firstName = "Asabeneh";
2-
let letlastName = "Yetayeh";
3-
var age = 200; // number data type
4-
var country = "Finland";
5-
var job = 'teacher';
6-
let lang = 'JavaScript'
7-
var personInfo = `I am ${fullName}.I am a ${age} years old. I am a ${job} and I love teaching.
1+
let firstName = 'Asabeneh';
2+
let letlastName = 'Yetayeh';
3+
let age = 200; // number data type
4+
let country = 'Finland';
5+
let job = 'teacher';
6+
let lang = 'JavaScript';
7+
let personInfo = `I am ${fullName}.I am a ${age} years old. I am a ${job} and I love teaching.
88
I live in ${country}.`; //ES6 - String interpolation method
99
console.log(personInfo);
1010

1111
let numberOne = 10;
1212
let numberTwo = 90;
13-
console.log(`The sum of ${numberOne} and ${numberTwo} is ${numberOne + numberTwo}.`);
13+
console.log(
14+
`The sum of ${numberOne} and ${numberTwo} is ${numberOne + numberTwo}.`
15+
);
1416
//More Examples
15-
var gravity = 9.81;
16-
var boilingPoint = 100;
17-
var bodyTemp = 37;
17+
let gravity = 9.81;
18+
let boilingPoint = 100;
19+
let bodyTemp = 37;
1820

1921
/*
2022
The boiling point of water is 100 oC.
2123
Human body temperatue is 37 oC.
2224
The gravity of earth is 9.81 m/s2.
2325
*/
24-
console.log(`The boiling point of water is ${boilingPoint} oC.\nHuman body temperatue is ${body} oC.\nThe gravity of earth is ${gravity} m / s2.`
26+
console.log(
27+
`The boiling point of water is ${boilingPoint} oC.\nHuman body temperatue is ${body} oC.\nThe gravity of earth is ${gravity} m / s2.`
2528
);
26-
27-
28-

05-string-method.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
/*
22
=== String Built in Methods ===
33
*/
4-
let firstName = "Asabeneh";
5-
let lastName = "Yetayeh";
6-
let location = "Helsinki";
4+
let firstName = 'Asabeneh';
5+
let lastName = 'Yetayeh';
6+
let location = 'Helsinki';
77
console.log(firstName.length); // to check the length of a string
88
console.log(firstName.toUpperCase()); // to capitalize
99
console.log(firstName.toLowerCase()); // to change to lower case letters
1010

11-
let company = 'google'
11+
let company = 'google';
1212

1313
var firstLetter = company.slice(0, 1); // to slice out the first letter of the word
1414
var remainingLetters = company.slice(1, company.length);
1515
console.log(firstLetter);
1616
console.log(remainingLetters);
1717
var modifiedName = firstLetter.toUpperCase() + remainingLetters;
1818
console.log(modifiedName);
19-
var school = "International Academy Award";
19+
var school = 'International Academy Award';
2020
console.log(school.split()); // creates an array of one item
21-
console.log(school.split("")); // it creates an array of letters and spaces;
22-
console.log(school.split(" ")); // creates an array of words
23-
console.log(school.indexOf("A")); // gives the index of the A in the string which is case sensitive
24-
console.log(school.lastIndexOf("A")); //the last A, which is A from the word Award
25-
console.log(school.includes("rify")); // it checks if the string exist and returns boolean
26-
console.log(school.includes("Award")); // it checks if the string exist and returns boolean
27-
console.log(school.includes("demy")); // it checks if the string exist and returns boolean
28-
console.log(school.startsWith("Inter")); // checks if the string starts with the provided value and returns boolean
21+
console.log(school.split('')); // it creates an array of letters and spaces;
22+
console.log(school.split(' ')); // creates an array of words
23+
console.log(school.indexOf('A')); // gives the index of the A in the string which is case sensitive
24+
console.log(school.lastIndexOf('A')); //the last A, which is A from the word Award
25+
console.log(school.includes('rify')); // it checks if the string exist and returns boolean
26+
console.log(school.includes('Award')); // it checks if the string exist and returns boolean
27+
console.log(school.includes('demy')); // it checks if the string exist and returns boolean
28+
console.log(school.startsWith('Inter')); // checks if the string starts with the provided value and returns boolean
2929

30-
var modifiedSchool = school.split(" ");
30+
var modifiedSchool = school.split(' ');
3131
console.log(modifiedSchool);

06-arthimetic_operators.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ let diff = numOne - numTwo;
66
let mult = numOne * numTwo;
77
let div = numOne / numTwo;
88
let remainder = numOne % numTwo;
9+
let exponentation = numOne ** numTwo // 4 * 4 * 4
910

1011
console.log(sum);
1112
console.log(diff);
1213
console.log(mult);
1314
console.log(div);
1415
console.log(remainder)
16+
console.log(exponentation)

09-typeof.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/*
22
=== Checking Data types ===
33
*/
4+
let firstName = 'Asabeneh';
5+
let age = 250;
6+
47
console.log (typeof firstName); // it gives string
58
console.log (typeof age); // it gives number
69
console.log (typeof firstName === 'string'); // returns true

10-if.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//if
22
let isRaining = true;
33
if (isRaining) {
4-
console.log("Remember to take your rain coat.");
4+
console.log('Remember to take your rain coat.');
55
}

11-ifelse.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//if else
22
if (isRaining) {
3-
console.log("It is raining. You need a rain coat.");
3+
console.log('It is raining. You need a rain coat.');
44
} else {
5-
console.log("It is not raining. No need for rain coat.");
5+
console.log('It is not raining. No need for rain coat.');
66
}

12-if-else-if-else.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// if else if else
22
let weather = 'sunny';
3-
if (weather === "rainy") {
4-
console.log("It is raining. You need a rain coat.");
5-
} else if (weather === "cloudy") {
6-
console.log("It might be cold you need a jacket.");
7-
} else if (weather === "sunny") {
8-
console.log("Go out freely.");
3+
if (weather === 'rainy') {
4+
console.log('It is raining. You need a rain coat.');
5+
} else if (weather === 'cloudy') {
6+
console.log('It might be cold you need a jacket.');
7+
} else if (weather === 'sunny') {
8+
console.log('Go out freely.');
99
} else {
10-
console.log("It is not raining. No need for rain coat.");
10+
console.log('It is not raining. No need for rain coat.');
1111
}

0 commit comments

Comments
 (0)