From e3369bd10b0b61c056a046b50ed0c498124498cf Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Sun, 11 Oct 2020 12:23:34 +0600 Subject: [PATCH 01/22] double quotes added in the string --- readMe.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/readMe.md b/readMe.md index 8a4bb39..6d68d4b 100644 --- a/readMe.md +++ b/readMe.md @@ -257,7 +257,7 @@ So far, we saw how to display text using the _console.log()_. If we are printing ```js console.log('Hello, World!') -console.log('Hello, World!') +console.log("Hello, World!") console.log(`Hello, World!`) ``` @@ -465,8 +465,9 @@ A collection of one or more characters between two single quotes, double quotes, 'Finland' 'JavaScript is a beautiful programming language' 'I love teaching' -'I hope you are enjoying the first day'`We can also create a string using a backtick` -;('A string could be just as small as one character as big as many pages') +"I hope you are enjoying the first day" +`We can also create a string using a backtick` +('A string could be just as small as one character as big as many pages') ``` ### Booleans From 649c7c054a9e837fe6f9ec4f2d21e88d7f7a0a21 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Sun, 11 Oct 2020 21:39:31 +0600 Subject: [PATCH 02/22] add some variation of Logarithmic function --- 02_Day_Data_types/02_day_data_types.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/02_Day_Data_types/02_day_data_types.md b/02_Day_Data_types/02_day_data_types.md index 198ae2b..0e82901 100644 --- a/02_Day_Data_types/02_day_data_types.md +++ b/02_Day_Data_types/02_day_data_types.md @@ -231,7 +231,16 @@ console.log(Math.E) // 2.718 console.log(Math.log(2)) // 0.6931471805599453 console.log(Math.log(10)) // 2.302585092994046 +// Returns the natural logarithm of 2 and 10 respectively +console.log(Math.LN2) // 0.6931471805599453 +console.log(Math.LN10) // 2.302585092994046 + +// Returns the natural logarithm with base 10 of x, Math.log10(x) +console.log(Math.log10(2)) // 0.3010299956639812 +console.log(Math.log10(10)) // 1 + // Trigonometry +// Returns the value in radians Math.sin(0) Math.sin(60) From 7bf81befc029a43309af977f2579a0c36ba92f57 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Sun, 11 Oct 2020 22:00:05 +0600 Subject: [PATCH 03/22] add values in trigonometric function --- 02_Day_Data_types/02_day_data_types.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/02_Day_Data_types/02_day_data_types.md b/02_Day_Data_types/02_day_data_types.md index 0e82901..5f8d186 100644 --- a/02_Day_Data_types/02_day_data_types.md +++ b/02_Day_Data_types/02_day_data_types.md @@ -235,17 +235,17 @@ console.log(Math.log(10)) // 2.302585092994046 console.log(Math.LN2) // 0.6931471805599453 console.log(Math.LN10) // 2.302585092994046 -// Returns the natural logarithm with base 10 of x, Math.log10(x) +// Returns the common logarithm with base 10 of x, Math.log10(x) console.log(Math.log10(2)) // 0.3010299956639812 console.log(Math.log10(10)) // 1 // Trigonometry // Returns the value in radians -Math.sin(0) -Math.sin(60) +Math.sin(0) // 0 +Math.sin(60) // -0.3048106211 -Math.cos(0) -Math.cos(60) +Math.cos(0) // 1 +Math.cos(60) // -0.95241298041 ``` #### Random Number Generator From db042caeda9049722f9cb09a13e53f01d1ef804f Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Tue, 13 Oct 2020 00:13:35 +0600 Subject: [PATCH 04/22] fix if else statement in checking items in a list --- 05_Day_Arrays/05_day_arrays.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/05_Day_Arrays/05_day_arrays.md b/05_Day_Arrays/05_day_arrays.md index 3374c12..3a92592 100644 --- a/05_Day_Arrays/05_day_arrays.md +++ b/05_Day_Arrays/05_day_arrays.md @@ -390,22 +390,24 @@ Check an element if it exist in an array. const fruits = ['banana', 'orange', 'mango', 'lemon'] let index = fruits.indexOf('banana') // 0 -if(index != -1){ +if(index === -1) { console.log('This fruit does exist in the array') } else { - console.log('This fruit does not exist in the array') + console.log('This fruit exists in the array') } -// This fruit does exist in the array +// This fruit exists in the array // we can use also ternary here -index != -1 ? console.log('This fruit does exist in the array'): console.log('This fruit does not exist in the array') +index === -1 +? console.log('This fruit does exist in the array') +: console.log('This fruit exists in the array') // let us check if a avocado exist in the array let indexOfAvocado = fruits.indexOf('avocado') // -1, if the element not found index is -1 -if(indexOfAvocado!= -1){ +if(indexOfAvocado === -1) { console.log('This fruit does exist in the array') } else { - console.log('This fruit does not exist in the array') + console.log('This fruit exists in the array') } // This fruit does not exist in the array ``` From f15f7b666bf1a89809e2d4f2f9af2da972729252 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Wed, 14 Oct 2020 11:57:56 +0600 Subject: [PATCH 05/22] fix for loop statement --- 06_Day_Loops/06_day_loops.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/06_Day_Loops/06_day_loops.md b/06_Day_Loops/06_day_loops.md index f0809fb..8458024 100644 --- a/06_Day_Loops/06_day_loops.md +++ b/06_Day_Loops/06_day_loops.md @@ -178,7 +178,7 @@ for (const num of numbers) { // adding all the numbers in the array let sum = 0 for (const num of numbers) { - sum += sum + num // can be also shorten like this, sum += num + sum = sum + num // can be also shorten like this, sum += num } console.log(sum) // 15 From 05800e350b0c86eee2a31c0236d944fad60d0a50 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Thu, 15 Oct 2020 20:27:06 +0600 Subject: [PATCH 06/22] remove unused parentheses --- 07_Day_Functions/07_day_functions.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/07_Day_Functions/07_day_functions.md b/07_Day_Functions/07_day_functions.md index 202ffad..bb57782 100644 --- a/07_Day_Functions/07_day_functions.md +++ b/07_Day_Functions/07_day_functions.md @@ -239,7 +239,7 @@ function sumAllNums() { console.log(arguments) } -sumAllNums(1, 2, 3, 4)) +sumAllNums(1, 2, 3, 4) // Arguments(4) [1, 2, 3, 4, callee: ƒ, Symbol(Symbol.iterator): ƒ] ``` @@ -269,11 +269,11 @@ console.log(sumAllNums(15, 20, 30, 25, 10, 33, 40)) // 173 ​ const sumAllNums = (...args) => { // console.log(arguments), arguments object not found in arrow function - // instead we use an a parameter followed by spread operator + // instead we use an a parameter followed by spread operator (...) console.log(args) } -sumAllNums(1, 2, 3, 4)) +sumAllNums(1, 2, 3, 4) // [1, 2, 3, 4] ``` From ff47e868240d6570d36083c0b0207a93702d4a55 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Fri, 16 Oct 2020 11:41:57 +0600 Subject: [PATCH 07/22] fix some typos on day 8 --- 08_Day_Objects/08_day_objects.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/08_Day_Objects/08_day_objects.md b/08_Day_Objects/08_day_objects.md index de91f2f..2b5bafa 100644 --- a/08_Day_Objects/08_day_objects.md +++ b/08_Day_Objects/08_day_objects.md @@ -125,7 +125,6 @@ Now, you have an understanding of scope. A variable declared with *var* only sco function letsLearnScope() { var gravity = 9.81 console.log(gravity) - } // console.log(gravity), Uncaught ReferenceError: gravity is not defined @@ -136,9 +135,9 @@ if (true){ console.log(gravity) // 9.81 for(var i = 0; i < 3; i++){ - console.log(i) // 1, 2, 3 + console.log(i) // 0, 1, 2 } -console.log(i) +console.log(i) // 3 ``` @@ -150,7 +149,6 @@ function letsLearnScope() { // you can use let or const, but gravity is constant I prefer to use const const gravity = 9.81 console.log(gravity) - } // console.log(gravity), Uncaught ReferenceError: gravity is not defined @@ -161,13 +159,13 @@ if (true){ // console.log(gravity), Uncaught ReferenceError: gravity is not defined for(let i = 0; i < 3; i++){ - console.log(i) // 1, 2, 3 + console.log(i) // 0, 1, 2 } // console.log(i), Uncaught ReferenceError: gravity is not defined ``` -The scope *let* and *const* is the same. The difference is only reassigning. We can not change or reassign the value of const variable. I would strongly suggest you to use *let* and *const*, by using *let* and *const* you will writ clean code and avoid hard to debug mistakes. As a rule of thumb, you can use *let* for any value which change, *const* for any constant value, and for array, object, arrow function and function expression. +The scope *let* and *const* are the same. The difference is only reassigning. We can not change or reassign the value of the const variable. I would strongly suggest you to use *let* and *const*, by using *let* and *const* you will write clean code and avoid hard to debug mistakes. As a rule of thumb, you can use *let* for any value which change, *const* for any constant value, and for an array, object, arrow function and function expression. ## 📔 Object @@ -250,14 +248,14 @@ const person = { console.log(person.firstName) console.log(person.lastName) console.log(person.age) -console.log(person.location) +console.log(person.location) // undefined value // value can be accessed using square bracket and key name console.log(person['firstName']) console.log(person['lastName']) console.log(person['age']) -console.log(person['age']) -console.log(person['location']) +console.log(person['city']) +console.log(person['location']) // undefined value // for instance to access the phone number we only use the square bracket method console.log(person['phone number']) From 3812010603b16f93569d5d634850efd8c8f08538 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Tue, 20 Oct 2020 01:22:24 +0600 Subject: [PATCH 08/22] fix typos in day 9 --- .../09_day_higher_order_functions.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/09_Day_Higher_order_functions/09_day_higher_order_functions.md b/09_Day_Higher_order_functions/09_day_higher_order_functions.md index 3c8a619..c8ab699 100644 --- a/09_Day_Higher_order_functions/09_day_higher_order_functions.md +++ b/09_Day_Higher_order_functions/09_day_higher_order_functions.md @@ -97,7 +97,7 @@ const sumArray = arr => { const callBack = function(element) { sum += element } - numbers.forEach(callback) + arr.forEach(callBack) return sum } @@ -115,7 +115,7 @@ const numbers = [1, 2, 3, 4] ​ const sumArray = arr => { let sum = 0 - numbers.forEach(function(element) { + arr.forEach(function(element) { sum += element }) return sum @@ -196,7 +196,7 @@ arr.forEach((element, index, arr) => console.log(index, element, arr)) ```js let sum = 0; const numbers = [1,2,3,4,5]; -numbers.forEach(num => console.log(num))) +numbers.forEach(num => console.log(num)) console.log(sum) ``` @@ -207,12 +207,13 @@ console.log(sum) 3 4 5 +0 ``` ```js let sum = 0; const numbers = [1,2,3,4,5]; -numbers.forEach(num => sum += num)) +numbers.forEach(num => sum += num) console.log(sum) ``` @@ -355,7 +356,7 @@ const scores = [ { name: 'John', score: 100 }, ] -const scoresGreaterEight = scores.filter((score) => score.score > 80) +const scoresGreaterEighty = scores.filter((score) => score.score > 80) console.log(scoresGreaterEight) ``` From 7b2b7f2e1ca426a986ca58a6834b6eab9f1fe369 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Tue, 20 Oct 2020 01:25:59 +0600 Subject: [PATCH 09/22] fix typo --- 09_Day_Higher_order_functions/09_day_higher_order_functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/09_Day_Higher_order_functions/09_day_higher_order_functions.md b/09_Day_Higher_order_functions/09_day_higher_order_functions.md index c8ab699..b94fe54 100644 --- a/09_Day_Higher_order_functions/09_day_higher_order_functions.md +++ b/09_Day_Higher_order_functions/09_day_higher_order_functions.md @@ -357,7 +357,7 @@ const scores = [ ] const scoresGreaterEighty = scores.filter((score) => score.score > 80) -console.log(scoresGreaterEight) +console.log(scoresGreaterEighty) ``` ```sh From 29a587e2b21efebd4509c3256e4391418e59a6d6 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Sun, 25 Oct 2020 13:04:35 +0600 Subject: [PATCH 10/22] fix typo, exercises level 3 output and day link --- 10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md | 21 ++++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md b/10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md index 6d0064c..a46d33d 100644 --- a/10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md +++ b/10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md @@ -246,7 +246,7 @@ Set(6) {1, 2, 3, 4, 5,6} ### Intersection of sets -To find an intersection of two sets can be achieved using filter. Lets find the union of set A and set B (A ∩ B) +To find an intersection of two sets can be achieved using filter. Lets find the intersection of set A and set B (A ∩ B) ```js let a = [1, 2, 3, 4, 5] @@ -417,7 +417,8 @@ const countries = ['Finland', 'Sweden', 'Norway'] ```js // Your output should look like this - console.log(mostSpokenLanguages(countries, 10))[ + console.log(mostSpokenLanguages(countries, 10)) + [ ({ English: 91 }, { French: 45 }, { Arabic: 25 }, @@ -433,19 +434,13 @@ const countries = ['Finland', 'Sweden', 'Norway'] // Your output should look like this console.log(mostSpokenLanguages(countries, 3)) + [ + {'English':91}, + {'French':45}, + {'Arabic':25} + ] ``` -[ -{'English':91}, -{'French':45}, -{'Arabic':25} -] - -``` - - 🎉 CONGRATULATIONS ! 🎉 - [<< Day 9](../09_Day_Higher_order_functions/09_day_higher_order_functions.md) | [Day 11>>](../11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md) -``` From d6fbf69b66bf26b7d2ae3719d5480dfd2d557ed6 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Mon, 26 Oct 2020 20:57:41 +0600 Subject: [PATCH 11/22] reposition comment --- .../11_day_destructuring_and_spreading.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md b/11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md index 5f0e896..7395a6a 100644 --- a/11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md +++ b/11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md @@ -258,7 +258,6 @@ const calculatePerimeter = rectangle => { } console.log(calculatePerimeter(rect)) // 60 -//with destructuring ``` ```js @@ -305,7 +304,7 @@ console.log(getPersonInfo(person)) ### Object parameter with destructuring ```js - +//with destructuring const calculatePerimeter = ({ width, height }) => { return 2 * (width + height) } From 7985dc1b9d2fe0b3d0c9af335266bda3620f9c65 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Wed, 28 Oct 2020 23:06:28 +0600 Subject: [PATCH 12/22] fix some error in day 12 --- .../12_day_regular_expressions.md | 141 +++++++++--------- 1 file changed, 71 insertions(+), 70 deletions(-) diff --git a/12_Day_Regular_expressions/12_day_regular_expressions.md b/12_Day_Regular_expressions/12_day_regular_expressions.md index 99d85f0..94e132f 100644 --- a/12_Day_Regular_expressions/12_day_regular_expressions.md +++ b/12_Day_Regular_expressions/12_day_regular_expressions.md @@ -348,7 +348,7 @@ Zero or many times. The pattern could may not occur or it can occur many times. ```js -const pattern = /[a].*/g //. any character, + any character one or more times +const pattern = /[a].*/g //. any character, * any character zero or more times const txt = 'Apple and banana are fruits' const matches = txt.match(pattern) @@ -434,91 +434,92 @@ points = ['-1', '2', '-4', '-3', '-1', '0', '4', '8'] sortedPoints = [-4, -3, -1, -1, 0, 2, 4, 8] distance = 12 ``` - 1. Write a pattern which identify if a string is a valid JavaScript variable - ```sh - is_valid_variable('first_name') # True - is_valid_variable('first-name') # False - is_valid_variable('1first_name') # False - is_valid_variable('firstname') # True - ``` +```sh +is_valid_variable('first_name') # True +is_valid_variable('first-name') # False +is_valid_variable('1first_name') # False +is_valid_variable('firstname') # True +``` ### Exercises: Level 2 1. Write a function called *tenMostFrequentWords* which get the ten most frequent word from a string? - ```js - paragraph = `I love teaching. If you do not love teaching what else can you love. I love Python if you do not love something which can give you all the capabilities to develop an application what else can you love.` - console.log(tenMostFrequentWords(paragraph)) - ``` - - ```sh - [ - {word:'love', count:6}, - {word:'you', count:5}, - {word:'can', count:3}, - {word:'what', count:2}, - {word:'teaching', count:2}, - {word:'not', count:2}, - {word:'else', count:2}, - {word:'do', count:2}, - {word:'I', count:2}, - {word:'which', count:1}, - {word:'to', count:1}, - {word:'the', count:1}, - {word:'something', count:1}, - {word:'if', count:1}, - {word:'give', count:1}, - {word:'develop',count:1}, - {word:'capabilities',count:1}, - {word:'application', count:1}, - {word:'an',count:1}, - {word:'all',count:1}, - {word:'Python',count:1}, - {word:'If',count:1}] - ``` - - ```js - console.log(tenMostFrequentWords(paragraph, 10)) - ``` - - ```sh - [{word:'love', count:6}, - {word:'you', count:5}, - {word:'can', count:3}, - {word:'what', count:2}, - {word:'teaching', count:2}, - {word:'not', count:2}, - {word:'else', count:2}, - {word:'do', count:2}, - {word:'I', count:2}, - {word:'which', count:1} - ] - ``` +```js +paragraph = `I love teaching. If you do not love teaching what else can you love. I love Python if you do not love something which can give you all the capabilities to develop an application what else can you love.` +console.log(tenMostFrequentWords(paragraph)) +``` + +```sh +[ +{word:'love', count:6}, +{word:'you', count:5}, +{word:'can', count:3}, +{word:'what', count:2}, +{word:'teaching', count:2}, +{word:'not', count:2}, +{word:'else', count:2}, +{word:'do', count:2}, +{word:'I', count:2}, +{word:'which', count:1}, +{word:'to', count:1}, +{word:'the', count:1}, +{word:'something', count:1}, +{word:'if', count:1}, +{word:'give', count:1}, +{word:'develop',count:1}, +{word:'capabilities',count:1}, +{word:'application', count:1}, +{word:'an',count:1}, +{word:'all',count:1}, +{word:'Python',count:1}, +{word:'If',count:1}] +``` + +```js +console.log(tenMostFrequentWords(paragraph, 10)) +``` + +```sh +[ +{word:'love', count:6}, +{word:'you', count:5}, +{word:'can', count:3}, +{word:'what', count:2}, +{word:'teaching', count:2}, +{word:'not', count:2}, +{word:'else', count:2}, +{word:'do', count:2}, +{word:'I', count:2}, +{word:'which', count:1} +] +``` ### Exercises: Level 3 -1. Writ a function which cleans text. Clean the following text. After cleaning, count three most frequent words in the string. +1. Write a function which cleans text. Clean the following text. After cleaning, count three most frequent words in the string. - ```js - sentence = `%I $am@% a %tea@cher%, &and& I lo%#ve %tea@ching%;. There $is nothing; &as& mo@re rewarding as educa@ting &and& @emp%o@wering peo@ple. ;I found tea@ching m%o@re interesting tha@n any other %jo@bs. %Do@es thi%s mo@tivate yo@u to be a tea@cher!?` +```js +sentence = `%I $am@% a %tea@cher%, &and& I lo%#ve %tea@ching%;. There $is nothing; &as& mo@re rewarding as educa@ting &and& @emp%o@wering peo@ple. ;I found tea@ching m%o@re interesting tha@n any other %jo@bs. %Do@es thi%s mo@tivate yo@u to be a tea@cher!?` - console.log(cleanText(sentence)) - ``` +console.log(cleanText(sentence)) +``` - ```sh - I am a teacher and I love teaching There is nothing as more rewarding as educating and empowering people I found teaching more interesting than any other jobs Does this motivate you to be a teacher - ``` +```sh +I am a teacher and I love teaching There is nothing as more rewarding as educating and empowering people I found teaching more interesting than any other jobs Does this motivate you to be a teacher +``` 1. Write a function which find the most frequent words. After cleaning, count three most frequent words in the string. - ```js - console.log(mostFrequentWords(cleanedText)) - [{word:'I', count:3}, {word:'teaching', count:2}, {word:'teacher', count:2}] - ``` +```js +console.log(mostFrequentWords(cleanedText)) +``` +```sh +[{word:'I', count:3}, {word:'teaching', count:2}, {word:'teacher', count:2}] +``` 🎉 CONGRATULATIONS ! 🎉 - -[<< Day 11](../11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md) | [Day 13>>](../13_Day_Console_object_methods/13_day_console_object_methods.md) +[<< Day 11](../11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md) | [Day 13>>](../13_Day_Console_object_methods/13_day_console_object_methods.md) \ No newline at end of file From 57348a559d2a0394db4d42386eac72384c9b6e20 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+KamrulSh@users.noreply.github.com> Date: Wed, 28 Oct 2020 23:26:53 +0600 Subject: [PATCH 13/22] fix indentation in exercises --- .../12_day_regular_expressions.md | 148 +++++++++--------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/12_Day_Regular_expressions/12_day_regular_expressions.md b/12_Day_Regular_expressions/12_day_regular_expressions.md index 94e132f..f332847 100644 --- a/12_Day_Regular_expressions/12_day_regular_expressions.md +++ b/12_Day_Regular_expressions/12_day_regular_expressions.md @@ -429,97 +429,97 @@ console.log(result) // true 1. Calculate the total annual income of the person from the following text. ‘He earns 4000 euro from salary per month, 10000 euro annual bonus, 5500 euro online courses per month.’ 1. The position of some particles on the horizontal x-axis -12, -4, -3 and -1 in the negative direction, 0 at origin, 4 and 8 in the positive direction. Extract these numbers and find the distance between the two furthest particles. -```js -points = ['-1', '2', '-4', '-3', '-1', '0', '4', '8'] -sortedPoints = [-4, -3, -1, -1, 0, 2, 4, 8] -distance = 12 -``` + ```js + points = ['-1', '2', '-4', '-3', '-1', '0', '4', '8'] + sortedPoints = [-4, -3, -1, -1, 0, 2, 4, 8] + distance = 12 + ``` 1. Write a pattern which identify if a string is a valid JavaScript variable -```sh -is_valid_variable('first_name') # True -is_valid_variable('first-name') # False -is_valid_variable('1first_name') # False -is_valid_variable('firstname') # True -``` + ```sh + is_valid_variable('first_name') # True + is_valid_variable('first-name') # False + is_valid_variable('1first_name') # False + is_valid_variable('firstname') # True + ``` ### Exercises: Level 2 1. Write a function called *tenMostFrequentWords* which get the ten most frequent word from a string? -```js -paragraph = `I love teaching. If you do not love teaching what else can you love. I love Python if you do not love something which can give you all the capabilities to develop an application what else can you love.` -console.log(tenMostFrequentWords(paragraph)) -``` - -```sh -[ -{word:'love', count:6}, -{word:'you', count:5}, -{word:'can', count:3}, -{word:'what', count:2}, -{word:'teaching', count:2}, -{word:'not', count:2}, -{word:'else', count:2}, -{word:'do', count:2}, -{word:'I', count:2}, -{word:'which', count:1}, -{word:'to', count:1}, -{word:'the', count:1}, -{word:'something', count:1}, -{word:'if', count:1}, -{word:'give', count:1}, -{word:'develop',count:1}, -{word:'capabilities',count:1}, -{word:'application', count:1}, -{word:'an',count:1}, -{word:'all',count:1}, -{word:'Python',count:1}, -{word:'If',count:1}] -``` - -```js -console.log(tenMostFrequentWords(paragraph, 10)) -``` - -```sh -[ -{word:'love', count:6}, -{word:'you', count:5}, -{word:'can', count:3}, -{word:'what', count:2}, -{word:'teaching', count:2}, -{word:'not', count:2}, -{word:'else', count:2}, -{word:'do', count:2}, -{word:'I', count:2}, -{word:'which', count:1} -] -``` + ```js + paragraph = `I love teaching. If you do not love teaching what else can you love. I love Python if you do not love something which can give you all the capabilities to develop an application what else can you love.` + console.log(tenMostFrequentWords(paragraph)) + ``` + + ```sh + [ + {word:'love', count:6}, + {word:'you', count:5}, + {word:'can', count:3}, + {word:'what', count:2}, + {word:'teaching', count:2}, + {word:'not', count:2}, + {word:'else', count:2}, + {word:'do', count:2}, + {word:'I', count:2}, + {word:'which', count:1}, + {word:'to', count:1}, + {word:'the', count:1}, + {word:'something', count:1}, + {word:'if', count:1}, + {word:'give', count:1}, + {word:'develop',count:1}, + {word:'capabilities',count:1}, + {word:'application', count:1}, + {word:'an',count:1}, + {word:'all',count:1}, + {word:'Python',count:1}, + {word:'If',count:1}] + ``` + + ```js + console.log(tenMostFrequentWords(paragraph, 10)) + ``` + + ```sh + [ + {word:'love', count:6}, + {word:'you', count:5}, + {word:'can', count:3}, + {word:'what', count:2}, + {word:'teaching', count:2}, + {word:'not', count:2}, + {word:'else', count:2}, + {word:'do', count:2}, + {word:'I', count:2}, + {word:'which', count:1} + ] + ``` ### Exercises: Level 3 1. Write a function which cleans text. Clean the following text. After cleaning, count three most frequent words in the string. -```js -sentence = `%I $am@% a %tea@cher%, &and& I lo%#ve %tea@ching%;. There $is nothing; &as& mo@re rewarding as educa@ting &and& @emp%o@wering peo@ple. ;I found tea@ching m%o@re interesting tha@n any other %jo@bs. %Do@es thi%s mo@tivate yo@u to be a tea@cher!?` + ```js + sentence = `%I $am@% a %tea@cher%, &and& I lo%#ve %tea@ching%;. There $is nothing; &as& mo@re rewarding as educa@ting &and& @emp%o@wering peo@ple. ;I found tea@ching m%o@re interesting tha@n any other %jo@bs. %Do@es thi%s mo@tivate yo@u to be a tea@cher!?` -console.log(cleanText(sentence)) -``` + console.log(cleanText(sentence)) + ``` -```sh -I am a teacher and I love teaching There is nothing as more rewarding as educating and empowering people I found teaching more interesting than any other jobs Does this motivate you to be a teacher -``` + ```sh + I am a teacher and I love teaching There is nothing as more rewarding as educating and empowering people I found teaching more interesting than any other jobs Does this motivate you to be a teacher + ``` 1. Write a function which find the most frequent words. After cleaning, count three most frequent words in the string. -```js -console.log(mostFrequentWords(cleanedText)) -``` + ```js + console.log(mostFrequentWords(cleanedText)) + ``` -```sh -[{word:'I', count:3}, {word:'teaching', count:2}, {word:'teacher', count:2}] -``` + ```sh + [{word:'I', count:3}, {word:'teaching', count:2}, {word:'teacher', count:2}] + ``` 🎉 CONGRATULATIONS ! 🎉 -[<< Day 11](../11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md) | [Day 13>>](../13_Day_Console_object_methods/13_day_console_object_methods.md) \ No newline at end of file +[<< Day 11](../11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md) | [Day 13>>](../13_Day_Console_object_methods/13_day_console_object_methods.md) From 464c9a9a04a8e17a46e2f0879c9dfe7b4964a351 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Thu, 29 Oct 2020 23:49:49 +0600 Subject: [PATCH 14/22] fix some minor mistakes --- 15_Day_Classes/15_day_classes.md | 80 ++++++++++++++++---------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/15_Day_Classes/15_day_classes.md b/15_Day_Classes/15_day_classes.md index 7b46328..c967078 100644 --- a/15_Day_Classes/15_day_classes.md +++ b/15_Day_Classes/15_day_classes.md @@ -66,13 +66,13 @@ class Person { } ``` -We have created an Person class but it does not have any thing inside. +We have created a Person class but it does not have anything inside. ### Class Instantiation Instantiation class means creating an object from a class. We need the keyword _new_ and we call the name of the class after the word new. -Let us create a dog object from our Person class. +Let us create a person object from our Person class. ```js class Person { @@ -92,7 +92,7 @@ Let use the class constructor to pass different properties for the class. ### Class Constructor -The constructor is a builtin function which allows as to create a blueprint for our object. The constructor function starts with a keyword constructor followed by a parenthesis. Inside the parenthesis we pass the properties of the object as parameter. We use the _this_ keyword to attach the constructor parameters with the class. +The constructor is a builtin function which allows us to create a blueprint for our object. The constructor function starts with a keyword constructor followed by a parenthesis. Inside the parenthesis we pass the properties of the object as parameter. We use the _this_ keyword to attach the constructor parameters with the class. The following Person class constructor has firstName and lastName property. These properties are attached to the Person class using _this_ keyword. _This_ refers to the class itself. @@ -111,7 +111,7 @@ console.log(person) ``` ```sh -Person {firstName: undefined, lastName} +Person {firstName: undefined, lastName: undefined} ``` All the keys of the object are undefined. When ever we instantiate we should pass the value of the properties. Let us pass value at this time when we instantiate the class. @@ -243,12 +243,12 @@ console.log(person2.getFullName()) ```sh Asabeneh Yetayeh -test.js:19 Lidiya Tekle +Lidiya Tekle ``` ### Properties with initial value -When we create a class for some properties we may have an initial value. For instance if you are playing a game, you starting score will be zero. So, we may have a starting score or score which is zero. In other way, we may have an initial skill and we will acquire some skill after some time. +When we create a class for some properties we may have an initial value. For instance if you are playing a game, your starting score will be zero. So, we may have a starting score or score which is zero. In other way, we may have an initial skill and we will acquire some skill after some time. ```js class Person { @@ -551,11 +551,11 @@ The static methods are methods which can be used as utility functions. ## Inheritance -Using inheritance we can access all the properties and the methods of the parent class. This reduces repetition of code. If you remember, we have a Person parent class and we will create children from it. Our children class could be student, teach etc. +Using inheritance we can access all the properties and the methods of the parent class. This reduces repetition of code. If you remember, we have a Person parent class and we will create children from it. Our children class could be student, teacher etc. ```js // syntax -class ChildClassName extends { +class ChildClassName extends ParentClassName { // code goes here } ``` @@ -675,38 +675,38 @@ Now, the getPersonInfo method has been overridden and it identifies if the perso 1. Let's try to develop a program which calculate measure of central tendency of a sample(mean, median, mode) and measure of variability(range, variance, standard deviation). In addition to those measures find the min, max, count, percentile, and frequency distribution of the sample. You can create a class called Statistics and create all the functions which do statistical calculations as method for the Statistics class. Check the output below. -```JS -ages = [31, 26, 34, 37, 27, 26, 32, 32, 26, 27, 27, 24, 32, 33, 27, 25, 26, 38, 37, 31, 34, 24, 33, 29, 26] - -console.log('Count:', statistics.count()) // 25 -console.log('Sum: ', statistics.sum()) // 744 -console.log('Min: ', statistics.min()) // 24 -console.log('Max: ', statistics.max()) // 38 -console.log('Range: ', statistics.range() // 14 -console.log('Mean: ', statistics.mean()) // 30 -console.log('Median: ',statistics.median()) // 29 -console.log('Mode: ', statistics.mode()) // {'mode': 26, 'count': 5} -console.log('Variance: ',statistics.var()) // 17.5 -console.log('Standard Deviation: ', statistics.std()) // 4.2 -console.log('Variance: ',statistics.var()) // 17.5 -console.log('Frequency Distribution: ',statistics.freqDist()) // [(20.0, 26), (16.0, 27), (12.0, 32), (8.0, 37), (8.0, 34), (8.0, 33), (8.0, 31), (8.0, 24), (4.0, 38), (4.0, 29), (4.0, 25)] -``` - -```sh -// you output should look like this -console.log(statistics.describe()) -Count: 25 -Sum: 744 -Min: 24 -Max: 38 -Range: 14 -Mean: 30 -Median: 29 -Mode: (26, 5) -Variance: 17.5 -Standard Deviation: 4.2 -Frequency Distribution: [(20.0, 26), (16.0, 27), (12.0, 32), (8.0, 37), (8.0, 34), (8.0, 33), (8.0, 31), (8.0, 24), (4.0, 38), (4.0, 29), (4.0, 25)] -``` + ```JS + ages = [31, 26, 34, 37, 27, 26, 32, 32, 26, 27, 27, 24, 32, 33, 27, 25, 26, 38, 37, 31, 34, 24, 33, 29, 26] + + console.log('Count:', statistics.count()) // 25 + console.log('Sum: ', statistics.sum()) // 744 + console.log('Min: ', statistics.min()) // 24 + console.log('Max: ', statistics.max()) // 38 + console.log('Range: ', statistics.range() // 14 + console.log('Mean: ', statistics.mean()) // 30 + console.log('Median: ',statistics.median()) // 29 + console.log('Mode: ', statistics.mode()) // {'mode': 26, 'count': 5} + console.log('Variance: ',statistics.var()) // 17.5 + console.log('Standard Deviation: ', statistics.std()) // 4.2 + console.log('Variance: ',statistics.var()) // 17.5 + console.log('Frequency Distribution: ',statistics.freqDist()) // [(20.0, 26), (16.0, 27), (12.0, 32), (8.0, 37), (8.0, 34), (8.0, 33), (8.0, 31), (8.0, 24), (4.0, 38), (4.0, 29), (4.0, 25)] + ``` + + ```sh + // you output should look like this + console.log(statistics.describe()) + Count: 25 + Sum: 744 + Min: 24 + Max: 38 + Range: 14 + Mean: 30 + Median: 29 + Mode: (26, 5) + Variance: 17.5 + Standard Deviation: 4.2 + Frequency Distribution: [(20.0, 26), (16.0, 27), (12.0, 32), (8.0, 37), (8.0, 34), (8.0, 33), (8.0, 31), (8.0, 24), (4.0, 38), (4.0, 29), (4.0, 25)] + ``` 1. Create a class called PersonAccount. It has firstname, lastname, incomes, expenses properties and it has totalIncome, totalExpense, accountInfo,addIncome, addExpense and accountBalance methods. Incomes is a set of incomes and its description and expenses is also a set of expenses and its description. From 35fe7066cb861f96cc9059fccb6e74c163547094 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Fri, 30 Oct 2020 11:53:42 +0600 Subject: [PATCH 15/22] fix some code output in day 15 --- 15_Day_Classes/15_day_classes.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/15_Day_Classes/15_day_classes.md b/15_Day_Classes/15_day_classes.md index c967078..b49fc94 100644 --- a/15_Day_Classes/15_day_classes.md +++ b/15_Day_Classes/15_day_classes.md @@ -569,7 +569,7 @@ class Student extends Person { } } -const s1 = new Student('Asabeneh', 'Yetayeh', 'Finland', 250, 'Helsinki') +const s1 = new Student('Asabeneh', 'Yetayeh', 250, 'Finland', 'Helsinki') console.log(s1) console.log(s1.saySomething()) console.log(s1.getFullName()) @@ -577,11 +577,10 @@ console.log(s1.getPersonInfo()) ``` ```sh -Student {firstName: "Asabeneh", lastName: "Yetayeh", age: "Finland", country: 250, city: "Helsinki", …} +Student {firstName: "Asabeneh", lastName: "Yetayeh", age: 250, country: "Finland", city: "Helsinki", …} I am a child of the person class Asabeneh Yetayeh -Student {firstName: "Asabeneh", lastName: "Yetayeh", age: "Finland", country: 250, city: "Helsinki", …} -Asabeneh Yetayeh is Finland. He lives Helsinki, 250. +Asabeneh Yetayeh is 250. He lives Helsinki, Finland. ``` ### Overriding methods @@ -605,8 +604,8 @@ class Student extends Person { this.skills.slice(0, this.skills.length - 1).join(', ') + ` and ${this.skills[this.skills.length - 1]}` - let formattedSkills = skills ? `He knows ${skills}` : '' let pronoun = this.gender == 'Male' ? 'He' : 'She' + let formattedSkills = skills ? `${pronoun} knows ${skills}` : '' let info = `${fullName} is ${this.age}. ${pronoun} lives in ${this.city}, ${this.country}. ${formattedSkills}` return info @@ -633,6 +632,7 @@ s2.setSkill = 'Managing' s2.setSkill = 'Organizing' console.log(s1) +console.log(s2) console.log(s1.saySomething()) console.log(s1.getFullName()) @@ -648,12 +648,10 @@ Student {firstName: "Asabeneh", lastName: "Yetayeh", age: 250, country: "Finlan Student {firstName: "Lidiya", lastName: "Tekle", age: 28, country: "Finland", city: "Helsinki", …} I am a child of the person class Asabeneh Yetayeh -Student {firstName: "Asabeneh", lastName: "Yetayeh", age: 250, country: "Finland", city: "Helsinki", …} Asabeneh Yetayeh is 250. He lives in Helsinki, Finland. He knows HTML, CSS and JavaScript I am a child of the person class Lidiya Tekle -Student {firstName: "Lidiya", lastName: "Tekle", age: 28, country: "Finland", city: "Helsinki", …} -Lidiya Tekle is 28. She lives in Helsinki, Finland. He knows Planning, Managing and Organizing +Lidiya Tekle is 28. She lives in Helsinki, Finland. She knows Planning, Managing and Organizing ``` Now, the getPersonInfo method has been overridden and it identifies if the person is male or female. From 539a22dd2ed026cb531df78701196f3498f5abd3 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Fri, 30 Oct 2020 12:00:01 +0600 Subject: [PATCH 16/22] code indent --- 15_Day_Classes/15_day_classes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/15_Day_Classes/15_day_classes.md b/15_Day_Classes/15_day_classes.md index b49fc94..55ba535 100644 --- a/15_Day_Classes/15_day_classes.md +++ b/15_Day_Classes/15_day_classes.md @@ -605,7 +605,7 @@ class Student extends Person { ` and ${this.skills[this.skills.length - 1]}` let pronoun = this.gender == 'Male' ? 'He' : 'She' - let formattedSkills = skills ? `${pronoun} knows ${skills}` : '' + let formattedSkills = skills ? `${pronoun} knows ${skills}` : '' let info = `${fullName} is ${this.age}. ${pronoun} lives in ${this.city}, ${this.country}. ${formattedSkills}` return info From 36288a0ac776ea18f3dfae4ae1cb3fedbee9ccc6 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Fri, 30 Oct 2020 12:17:43 +0600 Subject: [PATCH 17/22] fix code indent --- 05_Day_Arrays/05_day_arrays.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/05_Day_Arrays/05_day_arrays.md b/05_Day_Arrays/05_day_arrays.md index 3a92592..6922ea2 100644 --- a/05_Day_Arrays/05_day_arrays.md +++ b/05_Day_Arrays/05_day_arrays.md @@ -390,24 +390,24 @@ Check an element if it exist in an array. const fruits = ['banana', 'orange', 'mango', 'lemon'] let index = fruits.indexOf('banana') // 0 -if(index === -1) { +if(index != -1) { console.log('This fruit does exist in the array') } else { - console.log('This fruit exists in the array') + console.log('This fruit does not exist in the array') } // This fruit exists in the array // we can use also ternary here -index === -1 -? console.log('This fruit does exist in the array') -: console.log('This fruit exists in the array') +index != -1 + ? console.log('This fruit does exist in the array') + : console.log('This fruit does not exist in the array') // let us check if a avocado exist in the array let indexOfAvocado = fruits.indexOf('avocado') // -1, if the element not found index is -1 -if(indexOfAvocado === -1) { +if(indexOfAvocado != -1) { console.log('This fruit does exist in the array') } else { - console.log('This fruit exists in the array') + console.log('This fruit does not exist in the array') } // This fruit does not exist in the array ``` From 4376ba15fb53dcac18eb0a3906692c721e6a03a8 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Fri, 30 Oct 2020 12:21:42 +0600 Subject: [PATCH 18/22] edit comment --- 05_Day_Arrays/05_day_arrays.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/05_Day_Arrays/05_day_arrays.md b/05_Day_Arrays/05_day_arrays.md index 6922ea2..23e4dc9 100644 --- a/05_Day_Arrays/05_day_arrays.md +++ b/05_Day_Arrays/05_day_arrays.md @@ -395,7 +395,7 @@ if(index != -1) { } else { console.log('This fruit does not exist in the array') } -// This fruit exists in the array +// This fruit does exist in the array // we can use also ternary here index != -1 From 54923f4eb63f70d5cddba2d722230abbd2de461f Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Sun, 1 Nov 2020 23:52:19 +0600 Subject: [PATCH 19/22] fix some typos --- 16_Day_JSON/16_day_json.md | 4 ++-- 17_Day_Web_storages/17_day_web_storages.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/16_Day_JSON/16_day_json.md b/16_Day_JSON/16_day_json.md index 3cdfb40..fcb0686 100644 --- a/16_Day_JSON/16_day_json.md +++ b/16_Day_JSON/16_day_json.md @@ -63,7 +63,7 @@ JSON stands for JavaScript Object Notation. The JSON syntax is derived from Java } ``` -The above JSON example is not much different for a normal object. Then, what is the difference ? The difference is the key of a JSON object should be with double quotes or it should be a string. JavaScript Object and JSON are very similar that we can change JSON to Object and Object to JSON. +The above JSON example is not much different from a normal object. Then, what is the difference ? The difference is the key of a JSON object should be with double quotes or it should be a string. JavaScript Object and JSON are very similar that we can change JSON to Object and Object to JSON. Let us see the above example in more detail, it starts with a curly bracket. Inside the curly bracket, there is "users" key which has a value array. Inside the array we have different objects and each objects has keys, each keys has to have double quotes. For instance, we use "firstNaMe" instead of just firstName, however in object we use keys without double quotes. This is the major difference between an object and a JSON. Let's see more examples about JSON. @@ -590,7 +590,7 @@ const txt = `{ ### Exercises Level 3 1. Parse the *txt* JSON to object. -2. Find the the user who has many skills from the variable stored in *txt*. +2. Find the user who has many skills from the variable stored in *txt*. 🎉 CONGRATULATIONS ! 🎉 diff --git a/17_Day_Web_storages/17_day_web_storages.md b/17_Day_Web_storages/17_day_web_storages.md index f10d14d..ec4b2cb 100644 --- a/17_Day_Web_storages/17_day_web_storages.md +++ b/17_Day_Web_storages/17_day_web_storages.md @@ -77,7 +77,7 @@ For the examples mentioned above, it makes sense to use localStorage. You may be In cases, we want to to get rid of the data as soon as the window is closed. Or, perhaps, if we do not want the application to interfere with the same application that’s open in another window. These scenarios are served best with sessionStorage. -Now, let use how use make use of these Web Storage APIs. +Now, let us how users make use of these Web Storage APIs. ## HTML5 Web Storage Objects @@ -90,7 +90,7 @@ Web Storage objects: - _localStorage_ - to display the localStorage object - _localStorage.clear()_ - to remove everything in the local storage -- _localStorage.setItem()_ - to storage data in the localStorage. It takes a key and a value parameters. +- _localStorage.setItem()_ - to store data in the localStorage. It takes a key and a value parameters. - _localStorage.getItem()_ - to display data stored in the localStorage. It takes a key as a parameter. - _localStorage.removeItem()_ - to remove stored item form a localStorage. It takes key as a parameter. - _localStorage.key()_ - to display a data stored in a localStorage. It takes index as a parameter. From ced29fe7bfdbe04125b5820dbb4bb65924719466 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Mon, 2 Nov 2020 16:27:54 +0600 Subject: [PATCH 20/22] fix some typo error --- 18_Day_Promises/18_day_promises.md | 6 +++--- 19_Day_Closures/19_day_closures.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/18_Day_Promises/18_day_promises.md b/18_Day_Promises/18_day_promises.md index 6d7be2a..46656dc 100644 --- a/18_Day_Promises/18_day_promises.md +++ b/18_Day_Promises/18_day_promises.md @@ -106,7 +106,7 @@ doSomething((err, result) => { ### Promise constructor -We can create a promise using the Promise constructor. We can create a new promise using the key word new followed by the word Promise and followed by a parenthesis. Inside the parenthesis it it takes a callback function. The promise callback function has two parameters which are the *resolve* and *reject* functions. +We can create a promise using the Promise constructor. We can create a new promise using the key word *new* followed by the word Promise and followed by a parenthesis. Inside the parenthesis it takes a callback function. The promise callback function has two parameters which are the *resolve* and *reject* functions. ```js // syntax @@ -169,7 +169,7 @@ doPromise ## Fetch API -The Fetch API provides an interface for fetching resources (including across the network). It will seem familiar to anyone who has used XMLHttpRequest, but the new API provides a more powerful and flexible feature set. In this challenge we will use fetch to request url and APIS. In addition to that let us see demonstrate use case of promises in accessing network resources using the fetch API. +The Fetch API provides an interface for fetching resources (including across the network). It will seem familiar to anyone who has used XMLHttpRequest, but the new API provides a more powerful and flexible feature set. In this challenge we will use fetch to request url and APIs. In addition to that let us see demonstrate use case of promises in accessing network resources using the fetch API. ```js const url = 'https://restcountries.eu/rest/v2/all' // countries api @@ -244,7 +244,7 @@ console.log('===== async and await') fetchData() ``` -🌕 You are real and you kept your promise and your reached to day 18. Keep your promise and settle the challenge with resolve. You are 18 steps a head to your way to greatness. Now do some exercises for your brain and for your muscle. +🌕 You are real and you kept your promise and your reached to day 18. Keep your promise and settle the challenge with resolve. You are 18 steps ahead to your way to greatness. Now do some exercises for your brain and for your muscle. ## Exercises diff --git a/19_Day_Closures/19_day_closures.md b/19_Day_Closures/19_day_closures.md index 4c96016..57d3ff7 100644 --- a/19_Day_Closures/19_day_closures.md +++ b/19_Day_Closures/19_day_closures.md @@ -80,7 +80,7 @@ console.log(innerFuncs.minusOne) ```sh 1 -1 +0 ``` 🌕 You are making progress. Maintain your momentum, keep the good work. Now do some exercises for your brain and for your muscle. From a9655f536eb1762b63ee4a2082b037a34152790f Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Mon, 2 Nov 2020 23:53:24 +0600 Subject: [PATCH 21/22] fix some typos in day 20 --- 20_Day_Writing_clean_codes/20_day_writing_clean_codes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/20_Day_Writing_clean_codes/20_day_writing_clean_codes.md b/20_Day_Writing_clean_codes/20_day_writing_clean_codes.md index 50ed23a..017dd47 100644 --- a/20_Day_Writing_clean_codes/20_day_writing_clean_codes.md +++ b/20_Day_Writing_clean_codes/20_day_writing_clean_codes.md @@ -196,7 +196,7 @@ const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook'] // iterating an array using regular for loop let len = names.length; for(let i = 0; i < len; i++){ - console.log(names[i].toUpperCas()) + console.log(names[i].toUpperCase()) } @@ -218,7 +218,7 @@ const person = { skills: ['HTML','CSS','JavaScript','React','Node','MongoDB','Python','D3.js'], isMarried: true } -for(const key in user) { +for(const key in person) { console.log(key) } From 190ba29960eb0f473cb891a01a8e36ff96ee97a1 Mon Sep 17 00:00:00 2001 From: Kamrul Islam Shahin <44506464+shahin-cuet@users.noreply.github.com> Date: Tue, 3 Nov 2020 22:23:34 +0600 Subject: [PATCH 22/22] fix some typo error in day 21, 23 --- 21_Day_DOM/21_day_dom.md | 14 +++++++------- 23_Day_Event_listeners/23_day_event_listeners.md | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/21_Day_DOM/21_day_dom.md b/21_Day_DOM/21_day_dom.md index 5755391..ce0e4a6 100644 --- a/21_Day_DOM/21_day_dom.md +++ b/21_Day_DOM/21_day_dom.md @@ -74,7 +74,7 @@ We can access already created element or elements using JavaScript. To access or #### Getting elements by tag name -**_getElementsByTagName()_**:takes a take name as a string parameter and this method returns an HTMLCollection object. An HTMLCollection is an array like object of HTML elements. The length property provides the size of the collection. Whenever we use this method we access the individual elements using index or after loop through each individual items. An HTMLCollection does not support all array methods therefore we should use regular for loop instead of forEach. +**_getElementsByTagName()_**:takes a tag name as a string parameter and this method returns an HTMLCollection object. An HTMLCollection is an array like object of HTML elements. The length property provides the size of the collection. Whenever we use this method we access the individual elements using index or after loop through each individual items. An HTMLCollection does not support all array methods therefore we should use regular for loop instead of forEach. ```js // syntax @@ -84,7 +84,7 @@ document.getElementsByTagName('tagname') ```js const allTitles = document.getElementsByTagName('h1') -console.log(allTitles) //HTMCollections +console.log(allTitles) //HTMLCollections console.log(allTitles.length) // 4 for (let i = 0; i < allTitles.length; i++) { @@ -104,7 +104,7 @@ document.getElementsByClassName('classname') ```js const allTitles = document.getElementsByClassName('title') -console.log(allTitles) //HTMCollections +console.log(allTitles) //HTMLCollections console.log(allTitles.length) // 4 for (let i = 0; i < allTitles.length; i++) { @@ -133,9 +133,9 @@ The _document.querySelector_ method can select an HTML or HTML elements by tag n **_querySelector_**: can be used to select HTML element by its tag name, id or class. If the tag name is used it selects only the first element. ```js -let firstTitle = document.querySelector('h1') // select the first available h2 element +let firstTitle = document.querySelector('h1') // select the first available h1 element let firstTitle = document.querySelector('#first-title') // select id with first-title -let firstTitle = document.querySelector('.title') // select the first available h2 element with class title +let firstTitle = document.querySelector('.title') // select the first available h1 element with class title ``` **_querySelectorAll_**: can be used to select html element by its tag name or class. It return a nodeList which is an array like object which support array methods. We can use **_for loop_** or **_forEach_** to loop through each nodeList elements. @@ -158,7 +158,7 @@ An attribute is added in the opening tag of HTML which gives additional informat ```js const titles = document.querySelectorAll('h1') -titles[3].class = 'title' +titles[3].className = 'title' titles[3].id = 'fourth-title' ``` @@ -214,7 +214,7 @@ const titles = document.querySelectorAll('h1') titles[3].textContent = 'Fourth Title' ``` -#### Adding Text Content using innHTML +#### Adding Text Content using innerHTML Most people get confused between _textContent_ and _innerHTML_. _textContent_ is meant to add text to an HTML element, however innerHTML can add a text or HTML element or elements as a child. diff --git a/23_Day_Event_listeners/23_day_event_listeners.md b/23_Day_Event_listeners/23_day_event_listeners.md index 1100593..58cb184 100644 --- a/23_Day_Event_listeners/23_day_event_listeners.md +++ b/23_Day_Event_listeners/23_day_event_listeners.md @@ -174,7 +174,7 @@ By now you are familiar with addEventListen method and how to attach event liste List of events: - click - when the element clicked -- dbclick - when the element double clicked +- dblclick - when the element double clicked - mouseenter - when the mouse point enter to the element - mouseleave - when the mouse pointer leave the element - mousemove - when the mouse pointer move on the element