diff --git a/01_Day/01_day_starter/helloworld.js b/01_Day_Introduction/01_day_starter/helloworld.js similarity index 100% rename from 01_Day/01_day_starter/helloworld.js rename to 01_Day_Introduction/01_day_starter/helloworld.js diff --git a/01_Day/01_day_starter/index.html b/01_Day_Introduction/01_day_starter/index.html similarity index 100% rename from 01_Day/01_day_starter/index.html rename to 01_Day_Introduction/01_day_starter/index.html diff --git a/01_Day/01_day_starter/introduction.js b/01_Day_Introduction/01_day_starter/introduction.js similarity index 100% rename from 01_Day/01_day_starter/introduction.js rename to 01_Day_Introduction/01_day_starter/introduction.js diff --git a/01_Day/01_day_starter/main.js b/01_Day_Introduction/01_day_starter/main.js similarity index 100% rename from 01_Day/01_day_starter/main.js rename to 01_Day_Introduction/01_day_starter/main.js diff --git a/01_Day/01_day_starter/varaible.js b/01_Day_Introduction/01_day_starter/varaible.js similarity index 100% rename from 01_Day/01_day_starter/varaible.js rename to 01_Day_Introduction/01_day_starter/varaible.js diff --git a/01_Day/variable.js b/01_Day_Introduction/variable.js similarity index 100% rename from 01_Day/variable.js rename to 01_Day_Introduction/variable.js diff --git a/02_Day/02_day_data_types.md b/02_Day_Data_types/02_day_data_types.md similarity index 98% rename from 02_Day/02_day_data_types.md rename to 02_Day_Data_types/02_day_data_types.md index 5f1180c8c..198ae2b26 100644 --- a/02_Day/02_day_data_types.md +++ b/02_Day_Data_types/02_day_data_types.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Data Types

@@ -14,7 +14,7 @@
-[<< Day 1](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/readMe.md) | [Day 3 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/03_Day/03_booleans_operators_date.md) +[<< Day 1](../readMe.md) | [Day 3 >>](../03_Day_Booleans_operators_date/03_booleans_operators_date.md) ![Thirty Days Of JavaScript](../images/banners/day_1_2.png) @@ -973,4 +973,4 @@ console.log(numInt) // 9 πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 1](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/readMe.md) | [Day 3 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/03_Day/03_booleans_operators_date.md) +[<< Day 1](../readMe.md) | [Day 3 >>](../03_Day_Booleans_operators_date/03_booleans_operators_date.md) diff --git a/02_Day/02_day_starter/index.html b/02_Day_Data_types/02_day_starter/index.html similarity index 100% rename from 02_Day/02_day_starter/index.html rename to 02_Day_Data_types/02_day_starter/index.html diff --git a/02_Day/02_day_starter/main.js b/02_Day_Data_types/02_day_starter/main.js similarity index 100% rename from 02_Day/02_day_starter/main.js rename to 02_Day_Data_types/02_day_starter/main.js diff --git a/02_Day/day_1_2.png b/02_Day_Data_types/day_1_2.png similarity index 100% rename from 02_Day/day_1_2.png rename to 02_Day_Data_types/day_1_2.png diff --git a/02_Day/math_object.js b/02_Day_Data_types/math_object.js similarity index 100% rename from 02_Day/math_object.js rename to 02_Day_Data_types/math_object.js diff --git a/02_Day/non_primitive_data_types.js b/02_Day_Data_types/non_primitive_data_types.js similarity index 100% rename from 02_Day/non_primitive_data_types.js rename to 02_Day_Data_types/non_primitive_data_types.js diff --git a/02_Day/number_data_types.js b/02_Day_Data_types/number_data_types.js similarity index 100% rename from 02_Day/number_data_types.js rename to 02_Day_Data_types/number_data_types.js diff --git a/02_Day/primitive_data_types.js b/02_Day_Data_types/primitive_data_types.js similarity index 100% rename from 02_Day/primitive_data_types.js rename to 02_Day_Data_types/primitive_data_types.js diff --git a/02_Day/string_concatenation.js b/02_Day_Data_types/string_concatenation.js similarity index 100% rename from 02_Day/string_concatenation.js rename to 02_Day_Data_types/string_concatenation.js diff --git a/02_Day/string_data_types.js b/02_Day_Data_types/string_data_types.js similarity index 100% rename from 02_Day/string_data_types.js rename to 02_Day_Data_types/string_data_types.js diff --git a/02_Day/string_methods/accessing_character.js b/02_Day_Data_types/string_methods/accessing_character.js similarity index 100% rename from 02_Day/string_methods/accessing_character.js rename to 02_Day_Data_types/string_methods/accessing_character.js diff --git a/02_Day/string_methods/char_at.js b/02_Day_Data_types/string_methods/char_at.js similarity index 100% rename from 02_Day/string_methods/char_at.js rename to 02_Day_Data_types/string_methods/char_at.js diff --git a/02_Day/string_methods/char_code_at.js b/02_Day_Data_types/string_methods/char_code_at.js similarity index 100% rename from 02_Day/string_methods/char_code_at.js rename to 02_Day_Data_types/string_methods/char_code_at.js diff --git a/02_Day/string_methods/concat.js b/02_Day_Data_types/string_methods/concat.js similarity index 100% rename from 02_Day/string_methods/concat.js rename to 02_Day_Data_types/string_methods/concat.js diff --git a/02_Day/string_methods/ends_with.js b/02_Day_Data_types/string_methods/ends_with.js similarity index 100% rename from 02_Day/string_methods/ends_with.js rename to 02_Day_Data_types/string_methods/ends_with.js diff --git a/02_Day/string_methods/includes.js b/02_Day_Data_types/string_methods/includes.js similarity index 100% rename from 02_Day/string_methods/includes.js rename to 02_Day_Data_types/string_methods/includes.js diff --git a/02_Day/string_methods/index_of.js b/02_Day_Data_types/string_methods/index_of.js similarity index 100% rename from 02_Day/string_methods/index_of.js rename to 02_Day_Data_types/string_methods/index_of.js diff --git a/02_Day/string_methods/last_index_of.js b/02_Day_Data_types/string_methods/last_index_of.js similarity index 100% rename from 02_Day/string_methods/last_index_of.js rename to 02_Day_Data_types/string_methods/last_index_of.js diff --git a/02_Day/string_methods/length.js b/02_Day_Data_types/string_methods/length.js similarity index 100% rename from 02_Day/string_methods/length.js rename to 02_Day_Data_types/string_methods/length.js diff --git a/02_Day/string_methods/match.js b/02_Day_Data_types/string_methods/match.js similarity index 100% rename from 02_Day/string_methods/match.js rename to 02_Day_Data_types/string_methods/match.js diff --git a/02_Day/string_methods/repeat.js b/02_Day_Data_types/string_methods/repeat.js similarity index 100% rename from 02_Day/string_methods/repeat.js rename to 02_Day_Data_types/string_methods/repeat.js diff --git a/02_Day/string_methods/replace.js b/02_Day_Data_types/string_methods/replace.js similarity index 100% rename from 02_Day/string_methods/replace.js rename to 02_Day_Data_types/string_methods/replace.js diff --git a/02_Day/string_methods/search.js b/02_Day_Data_types/string_methods/search.js similarity index 100% rename from 02_Day/string_methods/search.js rename to 02_Day_Data_types/string_methods/search.js diff --git a/02_Day/string_methods/split.js b/02_Day_Data_types/string_methods/split.js similarity index 100% rename from 02_Day/string_methods/split.js rename to 02_Day_Data_types/string_methods/split.js diff --git a/02_Day/string_methods/starts_with.js b/02_Day_Data_types/string_methods/starts_with.js similarity index 100% rename from 02_Day/string_methods/starts_with.js rename to 02_Day_Data_types/string_methods/starts_with.js diff --git a/02_Day/string_methods/substr.js b/02_Day_Data_types/string_methods/substr.js similarity index 100% rename from 02_Day/string_methods/substr.js rename to 02_Day_Data_types/string_methods/substr.js diff --git a/02_Day/string_methods/substring.js b/02_Day_Data_types/string_methods/substring.js similarity index 100% rename from 02_Day/string_methods/substring.js rename to 02_Day_Data_types/string_methods/substring.js diff --git a/02_Day/string_methods/to_lowercase.js b/02_Day_Data_types/string_methods/to_lowercase.js similarity index 100% rename from 02_Day/string_methods/to_lowercase.js rename to 02_Day_Data_types/string_methods/to_lowercase.js diff --git a/02_Day/string_methods/to_uppercase.js b/02_Day_Data_types/string_methods/to_uppercase.js similarity index 100% rename from 02_Day/string_methods/to_uppercase.js rename to 02_Day_Data_types/string_methods/to_uppercase.js diff --git a/02_Day/string_methods/trim.js b/02_Day_Data_types/string_methods/trim.js similarity index 100% rename from 02_Day/string_methods/trim.js rename to 02_Day_Data_types/string_methods/trim.js diff --git a/03_Day/03_booleans_operators_date.md b/03_Day_Booleans_operators_date/03_booleans_operators_date.md similarity index 96% rename from 03_Day/03_booleans_operators_date.md rename to 03_Day_Booleans_operators_date/03_booleans_operators_date.md index c7236cbb0..1b5298e01 100644 --- a/03_Day/03_booleans_operators_date.md +++ b/03_Day_Booleans_operators_date/03_booleans_operators_date.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Booleans, Operators, Date

@@ -13,7 +13,7 @@
-[<< Day 2](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/02_Day/02_day_data_types.md) | [Day 4 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/04_Day/04_day_conditionals.md) +[<< Day 2](../02_Day_Data_types/02_day_data_types.md) | [Day 4 >>](../04_Day_Conditionals/04_day_conditionals.md) ![Thirty Days Of JavaScript](../images/banners/day_1_3.png) @@ -272,7 +272,7 @@ console.log(count++) // 0 console.log(count) // 1 ``` -We use most of the time post-increment. At leas you should remember how to use post-increment operator. +We use most of the time post-increment. At least you should remember how to use post-increment operator. ### Decrement Operator @@ -571,7 +571,7 @@ console.log(`${date}/${month}/${year} ${hours}:${minutes}`) // 4/1/2020 0:56 1. Slope is (m = y2-y1/x2-x1). Find the slope between point (2, 2) and point(6,10) 1. Compare the slope of above two questions. 1. Calculate the value of y (y = x^2 + 6x + 9). Try to use different x values and figure out at what x value y is 0. -1. Writ a script that prompt a user to enters hours and rate per hour. Calculate pay of the person? +1. Writ a script that prompt a user to enter hours and rate per hour. Calculate pay of the person? ```sh Enter hours: 40 @@ -630,6 +630,4 @@ console.log(`${date}/${month}/${year} ${hours}:${minutes}`) // 4/1/2020 0:56 1. Create a human readable time format using the Date time object. The hour and the minute should be all the time two digits(7 hours should be 07 and 5 minutes should be 05 ) 1. YYY-MM-DD HH:mm eg. 20120-01-02 07:05 -πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ - -[<< Day 2](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/02_Day/02_day_data_types.md) | [Day 4 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/04_Day/04_day_conditionals.md) +[<< Day 2](../02_Day_Data_types/02_day_data_types.md) | [Day 4 >>](../04_Day_Conditionals/04_day_conditionals.md) diff --git a/03_Day/03_day_starter/index.html b/03_Day_Booleans_operators_date/03_day_starter/index.html similarity index 100% rename from 03_Day/03_day_starter/index.html rename to 03_Day_Booleans_operators_date/03_day_starter/index.html diff --git a/03_Day/03_day_starter/scripts/main.js b/03_Day_Booleans_operators_date/03_day_starter/scripts/main.js similarity index 100% rename from 03_Day/03_day_starter/scripts/main.js rename to 03_Day_Booleans_operators_date/03_day_starter/scripts/main.js diff --git a/04_Day/04_day_conditionals.md b/04_Day_Conditionals/04_day_conditionals.md similarity index 71% rename from 04_Day/04_day_conditionals.md rename to 04_Day_Conditionals/04_day_conditionals.md index 7d4569f9f..b2a935a80 100644 --- a/04_Day/04_day_conditionals.md +++ b/04_Day_Conditionals/04_day_conditionals.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Conditionals

@@ -13,15 +13,15 @@
-[<< Day 3](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/03_Day/03_booleans_operators_date.md) | [Day 5 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/05_Day/05_day_arrays.md) +[<< Day 3](../03_Day_Booleans_operators_date/03_booleans_operators_date.md) | [Day 5 >>](../05_Day_Arrays/05_day_arrays.md) ![Thirty Days Of JavaScript](../images/banners/day_1_4.png) - [πŸ“” Day 4](#-day-4) - [Conditionals](#conditionals) - - [if](#if) - - [if else](#if-else) - - [if else if else](#if-else-if-else) + - [If](#if) + - [If Else](#if-else) + - [If Else if Else](#if-else-if-else) - [Switch](#switch) - [Ternary Operators](#ternary-operators) - [πŸ’» Exercises](#-exercises) @@ -33,11 +33,11 @@ ## Conditionals -Conditional statements are used to make decisions based on different conditions. +Conditional statements are used for make decisions based on different conditions. By default , statements in JavaScript script executed sequentially from top to bottom. If the processing logic require so, the sequential flow of execution can be altered in two ways: - Conditional execution: a block of one or more statements will be executed if a certain expression is true -- Repetitive execution: a block of one or more statements will be repetitively executed as long as a certain expression is true. In this section, we will cover _if_, _else_ , _else if_ statements. The comparison and logical operator we learned in the previous sections will be useful in here. +- Repetitive execution: a block of one or more statements will be repetitively executed as long as a certain expression is true. In this section, we will cover _if_, _else_ , _else if_ statements. The comparison and logical operators we learned in the previous sections will be useful in here. Conditions can be implementing using the following ways: @@ -47,14 +47,14 @@ Conditions can be implementing using the following ways: - switch - ternary operator -### if +### If -In JavaScript and other programming languages the key word _if_ is used to check if a condition is true and to execute the block code. To create an if condition, we need _if_ keyword, condition inside a parenthesis and block of code inside a curly bracket({}). +In JavaScript and other programming languages the key word _if_ is to used check if a condition is true and to execute the block code. To create an if condition, we need _if_ keyword, condition inside a parenthesis and block of code inside a curly bracket({}). ```js // syntax if (condition) { - //this part of code run for truthy condition + //this part of code runs for truthy condition } ``` @@ -68,7 +68,7 @@ if (num > 0) { // 3 is a positive number ``` -As you can see in the above condition, 3 is greater than 0 and it is a positive number. The condition was true and the block code was executed. However, if the condition is false, we do not see a result. +As you can see in the condition example above, 3 is greater than 0, so it is a positive number. The condition was true and the block of code was executed. However, if the condition is false, we won't see any results. ```js let isRaining = true @@ -77,18 +77,18 @@ if (isRaining) { } ``` - The same goes for the second condition, if isRaining is false the if block will not be executed and we do not see an output. In order to see the result of the falsy condition, we should have another block, which is going to be _else_. + The same goes for the second condition, if isRaining is false the if block will not be executed and we do not see any output. In order to see the result of a falsy condition, we should have another block, which is going to be _else_. -### if else +### If Else If condition is true the first block will be executed, if not the else condition will be executed. ```js // syntax if (condition) { - // this part of code run for truthy condition + // this part of code runs for truthy condition } else { - // this part of code run for false condition + // this part of code runs for false condition } ``` @@ -128,11 +128,11 @@ if (isRaining) { // No need for a rain coat. ``` -The above condition is false, therefore the else block was executed. How about if our condition is more than two, we will use *else if* conditions. +The last condition is false, therefore the else block was executed. What if we have more than two conditions? In that case, we would use *else if* conditions. -### if else if else +### If Else if Else -On our daily life, we make decision on daily basis. We make decision not by checking one or two conditions instead we make decisions based on multiple conditions. As similar to our daily life, programming is also full of conditions. We use *else if* when we have multiple conditions. +On our daily life, we make decisions on daily basis. We make decisions not by checking one or two conditions instead we make decisions based on multiple conditions. As similar to our daily life, programming is also full of conditions. We use *else if* when we have multiple conditions. ```js // syntax @@ -178,7 +178,7 @@ if (weather === 'rainy') { ### Switch Switch is an alternative for **if else if else else**. -The switch statement starts with a switch keyword followed by a parenthesis and code block. Inside the code block we will have different cases. Case block run if the value in the switch statement parenthesis match with the case vale. The break is to terminate and it does not go down after the condition is satisfied. The default block run if all the cases don't satisfy the condition. +The switch statement starts with a *switch* keyword followed by a parenthesis and code block. Inside the code block we will have different cases. Case block runs if the value in the switch statement parenthesis matches with the case value. The break statement is to terminate execution so the code execution does not go down after the condition is satisfied. The default block runs if all the cases don't satisfy the condition. ```js switch(caseValue){ @@ -264,7 +264,7 @@ switch (true) { ### Ternary Operators -Another way to write conditionals is using ternary operators. We have covered this in other sections but we should also mention it here. +Another way to write conditionals is using ternary operators. We have covered this in other sections, but we should also mention it here. ```js let isRaining = true @@ -273,13 +273,13 @@ isRaining : console.log('No need for a rain coat.') ``` -πŸŒ• You are extraordinary and you have a remarkable potential. You have just completed day 4 challenges and you are four steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle. +πŸŒ• You are extraordinary and you have a remarkable potential. You have just completed day 4 challenges and you are four steps ahead to your way to greatness. Now do some exercises for your brain and muscle. ## πŸ’» Exercises ### Exercises: Level 1 -1. Get user input using prompt(β€œEnter your age:”). If user is 18 or older , give feedback:You are old enough to drive but if not 18 give feedback to wait for the years he supposed to wait for. +1. Get user input using prompt(β€œEnter your age:”). If user is 18 or older , give feedback:'You are old enough to drive' but if not 18 give another feedback stating to wait for the number of years he neds to turn 18. ```sh Enter your age: 30 @@ -289,14 +289,14 @@ isRaining You are left with 3 years to drive. ``` -1. Compare the values of myAge and yourAge using if … else. Based on the comparison log to console who is older (me or you). Use prompt(β€œEnter your age:”) to get the age as input. +1. Compare the values of myAge and yourAge using if … else. Based on the comparison and log the result to console stating who is older (me or you). Use prompt(β€œEnter your age:”) to get the age as input. ```sh Enter your age: 30 You are 5 years older than me. ``` -1. If a is greater than b return 'a is greater than b' else 'a is less than b'. Try to implement in to ways +1. If a is greater than b return 'a is greater than b' else 'a is less than b'. Try to implement it in to ways - using if else - ternary operator. @@ -310,7 +310,7 @@ isRaining 4 is greater than 3 ``` -1. Even numbers are divisible by 2 and the remainder is zero. How do you check if a number is even or not using JavaScript? +1. Even numbers are divisible by 2 and the remainder is zero. How do you check, if a number is even or not using JavaScript? ```sh Enter a number: 2 @@ -322,14 +322,14 @@ isRaining ### Exercises: Level 2 -1. Write a code which can give grade to students according to theirs scores: +1. Write a code which can give grades to students according to theirs scores: - 80-100, A - 70-89, B - 60-69, C - 50-59, D - 0-49, F 1. Check if the season is Autumn, Winter, Spring or Summer. - If the user input is: + If the user input is : - September, October or November, the season is Autumn. - December, January or February, the season is Winter. - March, April or May, the season is Spring @@ -368,6 +368,9 @@ isRaining February has 28 days. ``` +1. Write a program which tells the number of days in a month, now consider leap year. + + πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 3](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/03_Day/03_booleans_operators_date.md) | [Day 5 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/05_Day/05_day_arrays.md) +[<< Day 3](../03_Day_Booleans_operators_date/03_booleans_operators_date.md) | [Day 5 >>](../05_Day_Arrays/05_day_arrays.md) diff --git a/04_Day/04_day_starter/index.html b/04_Day_Conditionals/04_day_starter/index.html similarity index 100% rename from 04_Day/04_day_starter/index.html rename to 04_Day_Conditionals/04_day_starter/index.html diff --git a/04_Day/04_day_starter/scripts/main.js b/04_Day_Conditionals/04_day_starter/scripts/main.js similarity index 100% rename from 04_Day/04_day_starter/scripts/main.js rename to 04_Day_Conditionals/04_day_starter/scripts/main.js diff --git a/05_Day/05_day_arrays.md b/05_Day_Arrays/05_day_arrays.md similarity index 98% rename from 05_Day/05_day_arrays.md rename to 05_Day_Arrays/05_day_arrays.md index 06f9308f4..3374c1280 100644 --- a/05_Day/05_day_arrays.md +++ b/05_Day_Arrays/05_day_arrays.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Arrays

@@ -13,7 +13,7 @@
-[<< Day 4](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/04_Day/04_day_conditionals.md) | [Day 6 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/06_Day/06_day_loops.md) +[<< Day 4](../04_Day_Conditionals/04_day_Conditionals.md) | [Day 6 >>](../06_Day_Loops/06_day_loops.md) ![Day 5](../images/banners/day_1_5.png) @@ -776,4 +776,4 @@ const webTechs = [ πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 4](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/04_Day/04_day_conditionals.md) | [Day 6 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/06_Day/06_day_loops.md) +[<< Day 4](../04_Day_Conditionals/04_day_Conditionals.md) | [Day 6 >>](../06_Day_Loops/06_day_loops.md) diff --git a/05_Day/05_day_starter/data/countries.js b/05_Day_Arrays/05_day_starter/data/countries.js similarity index 100% rename from 05_Day/05_day_starter/data/countries.js rename to 05_Day_Arrays/05_day_starter/data/countries.js diff --git a/05_Day/05_day_starter/index.html b/05_Day_Arrays/05_day_starter/index.html similarity index 100% rename from 05_Day/05_day_starter/index.html rename to 05_Day_Arrays/05_day_starter/index.html diff --git a/05_Day/05_day_starter/scripts/main.js b/05_Day_Arrays/05_day_starter/scripts/main.js similarity index 100% rename from 05_Day/05_day_starter/scripts/main.js rename to 05_Day_Arrays/05_day_starter/scripts/main.js diff --git a/06_Day/06_day_loops.md b/06_Day_Loops/06_day_loops.md similarity index 96% rename from 06_Day/06_day_loops.md rename to 06_Day_Loops/06_day_loops.md index 16f439518..f0809fbf7 100644 --- a/06_Day/06_day_loops.md +++ b/06_Day_Loops/06_day_loops.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Loops

@@ -13,7 +13,7 @@
-[<< Day 5](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/05_Day/05_day_arrays.md) | [Day 7 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/07_Day/07_day_functions.md) +[<< Day 5](../05_Day_Arrays/05_day_arrays.md) | [Day 7 >>](../07_Day_Functions/07_day_functions.md) ![Day 5](../images/banners/day_1_6.png) @@ -34,7 +34,7 @@ ## Loops -Most of the activities we do in life are full of repetitions. Imagine if I ask you to print out from 0 to 100 using console.log(). To implement this simple task it may take you 2 to 5 minutes, such kind of tedious and repetitive task can be carried out using loop. +Most of the activities we do in life are full of repetitions. Imagine if I ask you to print out from 0 to 100 using console.log(). To implement this simple task it may take you 2 to 5 minutes, such kind of tedious and repetitive task can be carried out using loop. If you prefer watching the videos, you can checkout the [video tutorials](https://www.youtube.com/channel/UCM4xOopkYiPwJqyKsSqL9mw) In programming languages to carry out repetitive task we use different kinds of loops. The following examples are the commonly used loops in JavaScript and other programming languages. @@ -478,4 +478,4 @@ for(let i = 0; i <= 5; i++){ πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 5](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/05_Day/05_day_arrays.md) | [Day 7 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/07_Day/07_day_functions.md) +[<< Day 5](../05_Day_Arrays/05_day_arrays.md) | [Day 7 >>](../07_Day_Functions/07_day_functions.md) diff --git a/06_Day/06_day_starter/data/countries.js b/06_Day_Loops/06_day_starter/data/countries.js similarity index 100% rename from 06_Day/06_day_starter/data/countries.js rename to 06_Day_Loops/06_day_starter/data/countries.js diff --git a/06_Day/06_day_starter/index.html b/06_Day_Loops/06_day_starter/index.html similarity index 100% rename from 06_Day/06_day_starter/index.html rename to 06_Day_Loops/06_day_starter/index.html diff --git a/06_Day/06_day_starter/scripts/main.js b/06_Day_Loops/06_day_starter/scripts/main.js similarity index 100% rename from 06_Day/06_day_starter/scripts/main.js rename to 06_Day_Loops/06_day_starter/scripts/main.js diff --git a/07_Day/07_day_functions.md b/07_Day_Functions/07_day_functions.md similarity index 98% rename from 07_Day/07_day_functions.md rename to 07_Day_Functions/07_day_functions.md index f247ddb0b..202ffadb9 100644 --- a/07_Day/07_day_functions.md +++ b/07_Day_Functions/07_day_functions.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Functions

@@ -13,7 +13,7 @@
-[<< Day 6](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/06_Day/06_day_loops.md) | [Day 8 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/08_Day/08_day_objects.md) +[<< Day 6](../06_Day_Loops/06_day_loops.md) | [Day 8 >>](../08_Day_Objects/08_day_objects.md) ![Thirty Days Of JavaScript](../images/banners/day_1_7.png) @@ -703,4 +703,4 @@ It ill be covered in other time πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 6](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/06_Day/06_day_loops.md) | [Day 8 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/08_Day/08_day_objects.md) +[<< Day 6](../06_Day_Loops/06_day_loops.md) | [Day 8 >>](../08_Day_Objects/08_day_objects.md) \ No newline at end of file diff --git a/07_Day/07_day_starter/data/countries.js b/07_Day_Functions/07_day_starter/data/countries.js similarity index 100% rename from 07_Day/07_day_starter/data/countries.js rename to 07_Day_Functions/07_day_starter/data/countries.js diff --git a/07_Day/07_day_starter/index.html b/07_Day_Functions/07_day_starter/index.html similarity index 100% rename from 07_Day/07_day_starter/index.html rename to 07_Day_Functions/07_day_starter/index.html diff --git a/07_Day/07_day_starter/scripts/main.js b/07_Day_Functions/07_day_starter/scripts/main.js similarity index 100% rename from 07_Day/07_day_starter/scripts/main.js rename to 07_Day_Functions/07_day_starter/scripts/main.js diff --git a/08_Day/08_day_objects.md b/08_Day_Objects/08_day_objects.md similarity index 96% rename from 08_Day/08_day_objects.md rename to 08_Day_Objects/08_day_objects.md index af281788a..de91f2f64 100644 --- a/08_Day/08_day_objects.md +++ b/08_Day_Objects/08_day_objects.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Objects

@@ -13,7 +13,7 @@
-[<< Day 7](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/07_Day/07_day_functions.md) | [Day 9 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/09_Day/09_day_higher_order_functions.md) +[<< Day 7](../07_Day_Functions/07_day_functions.md) | [Day 9 >>](../09_Day_Higher_order_functions/09_day_higher_order_functions.md) ![Thirty Days Of JavaScript](../images/banners/day_1_8.png) @@ -368,7 +368,7 @@ const person = { city: 'Helsinki' }, getPersonInfo: function() { - return `I am ${this.firstName} and I live in ${city}, ${this.country}. I am ${this.age}.` + return `I am ${this.firstName} and I live in ${this.city}, ${this.country}. I am ${this.age}.` } } @@ -586,4 +586,4 @@ console.log(copyPerson.hasOwnProperty('score')) πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 7](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/07_Day/07_day_functions.md) | [Day 9 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/09_Day/09_day_higher_order_functions.md) +[<< Day 7](../07_Day_Functions/07_day_functions.md) | [Day 9 >>](../09_Day_Higher_order_functions/09_day_higher_order_functions.md) diff --git a/08_Day/08_day_starter/data/countries_data.js b/08_Day_Objects/08_day_starter/data/countries_data.js similarity index 100% rename from 08_Day/08_day_starter/data/countries_data.js rename to 08_Day_Objects/08_day_starter/data/countries_data.js diff --git a/08_Day/08_day_starter/index.html b/08_Day_Objects/08_day_starter/index.html similarity index 100% rename from 08_Day/08_day_starter/index.html rename to 08_Day_Objects/08_day_starter/index.html diff --git a/08_Day/08_day_starter/scripts/main.js b/08_Day_Objects/08_day_starter/scripts/main.js similarity index 100% rename from 08_Day/08_day_starter/scripts/main.js rename to 08_Day_Objects/08_day_starter/scripts/main.js diff --git a/09_Day/09_day_higher_order_functions.md b/09_Day_Higher_order_functions/09_day_higher_order_functions.md similarity index 70% rename from 09_Day/09_day_higher_order_functions.md rename to 09_Day_Higher_order_functions/09_day_higher_order_functions.md index 8999fa7b1..3c8a6193d 100644 --- a/09_Day/09_day_higher_order_functions.md +++ b/09_Day_Higher_order_functions/09_day_higher_order_functions.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Higher Order Functions

@@ -7,13 +7,14 @@ Twitter Follow - Author: - Asabeneh Yetayeh
- January, 2020 -
+Author: +Asabeneh Yetayeh
+ January, 2020 +
+
-[<< Day 8](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/08_Day/08_day_objects.md) | [Day 10 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/10_Day/10_day_Set_and_Map.md) +[<< Day 8](../08_Day_Objects/08_day_objects.md) | [Day 10 >>](../10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md) ![Day 5](../images/banners/day_1_9.png) @@ -37,7 +38,7 @@ - [Sorting string values](#sorting-string-values) - [Sorting Numeric values](#sorting-numeric-values) - [Sorting Object Arrays](#sorting-object-arrays) - - [πŸ’» Exercises](#%f0%9f%92%bb-exercises) + - [πŸ’» Exercises](#-exercises) - [Exercises: Level 1](#exercises-level-1) - [Exercises: Level 2](#exercises-level-2) - [Exercises: Level 3](#exercises-level-3) @@ -181,7 +182,7 @@ Instead of writing regular loop, latest version of JavaScript introduced lots of _forEach_: Iterate an array elements. We use _forEach_ only with arrays. It takes a callback function with elements, index parameter and array itself. The index and the array optional. ```js -arr.forEach(function(element, index, arr) { +arr.forEach(function (element, index, arr) { console.log(index, element, arr) }) // The above code can be written using arrow function @@ -222,7 +223,7 @@ console.log(sum) ```js const countries = ['Finland', 'Denmark', 'Sweden', 'Norway', 'Iceland'] -countries.forEach(element => console.log(element.toUpperCase())) +countries.forEach((element) => console.log(element.toUpperCase())) ``` ```sh @@ -235,10 +236,10 @@ ICELAND ### map -_map_: Iterate an array elements and modify the array elements. It takes a callback function with elements and index parameter and return a new array. +_map_: Iterate an array elements and modify the array elements. It takes a callback function with elements, index , array parameter and return a new array. ```js -const modifiedArray = arr.map(function(element, index) { +const modifiedArray = arr.map(function (element, index, arr) { return element }) ``` @@ -249,7 +250,7 @@ const modifiedArray = arr.map((element,index) => element); */ //Example const numbers = [1, 2, 3, 4, 5] -const numbersSquare = numbers.map(num => num * num) +const numbersSquare = numbers.map((num) => num * num) console.log(numbersSquare) ``` @@ -260,7 +261,7 @@ console.log(numbersSquare) ```js const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook'] -const namesToUpperCase = names.map(name => name.toUpperCase()) +const namesToUpperCase = names.map((name) => name.toUpperCase()) console.log(namesToUpperCase) ``` @@ -280,9 +281,9 @@ const countries = [ 'Hungary', 'Ireland', 'Japan', - 'Kenya' + 'Kenya', ] -const countriesToUpperCase = countries.map(country => country.toUpperCase()) +const countriesToUpperCase = countries.map((country) => country.toUpperCase()) console.log(countriesToUpperCase) /* @@ -300,7 +301,7 @@ const countriesToUpperCase = countries.map(country => country.toUpperCase()); ``` ```js -const countriesFirstThreeLetters = countries.map(country => +const countriesFirstThreeLetters = countries.map((country) => country.toUpperCase().slice(0, 3) ) ``` @@ -315,7 +316,7 @@ _Filter_: Filter out items which full fill filtering conditions and return a new ```js //Filter countries containing land -const countriesContainingLand = countries.filter(country => +const countriesContainingLand = countries.filter((country) => country.includes('land') ) console.log(countriesContainingLand) @@ -326,7 +327,7 @@ console.log(countriesContainingLand) ``` ```js -const countriesEndsByia = countries.filter(country => country.includes('ia')) +const countriesEndsByia = countries.filter((country) => country.endsWith('ia')) console.log(countriesEndsByia) ``` @@ -336,7 +337,7 @@ console.log(countriesEndsByia) ```js const countriesHaveFiveLetters = countries.filter( - country => country.length === 5 + (country) => country.length === 5 ) console.log(countriesHaveFiveLetters) ``` @@ -351,10 +352,10 @@ const scores = [ { name: 'Mathias', score: 80 }, { name: 'Elias', score: 50 }, { name: 'Martha', score: 85 }, - { name: 'John', score: 100 } + { name: 'John', score: 100 }, ] -const scoresGreaterEight = scores.filter(score => score.score > 80) +const scoresGreaterEight = scores.filter((score) => score.score > 80) console.log(scoresGreaterEight) ``` @@ -364,11 +365,18 @@ console.log(scoresGreaterEight) ### reduce -_reduce_: Reduce takes a callback function. The call back function takes accumulator and current value as a parameter and returns a single value: +_reduce_: Reduce takes a callback function. The call back function takes accumulator, current, and optional initial value as a parameter and returns a single value. It is a good practice to define an initial value for the accumulator value. If we do not specify this parameter, by default accumulator will get array `first value`. If our array is an _empty array_, then `Javascript` will throw an error. + +```js +arr.reduce((acc, cur) => { + // some operations goes here before returning a value + return +}, initialValue) +``` ```js const numbers = [1, 2, 3, 4, 5] -const sum = numbers.reduce((accum, curr) => accum + curr) +const sum = numbers.reduce((acc, cur) => acc + cur, 0) console.log(sum) ``` @@ -383,7 +391,7 @@ _every_: Check if all the elements are similar in one aspect. It returns boolean ```js const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook'] -const areAllStr = names.every(name => typeof name === 'string') +const areAllStr = names.every((name) => typeof name === 'string') console.log(arrAllStr) ``` @@ -394,7 +402,7 @@ true ```js const bools = [true, true, true, true] -const areAllTrue = bools.every(b => { +const areAllTrue = bools.every((b) => { return b === true }) @@ -412,7 +420,7 @@ _find_: Return the first element which satisfies the condition ```js const ages = [24, 22, 25, 32, 35, 18] -const age = ages.find(age => age < 20) +const age = ages.find((age) => age < 20) console.log(age) ``` @@ -423,7 +431,7 @@ console.log(age) ```js const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook'] -const result = names.find(name => name.length > 7) +const result = names.find((name) => name.length > 7) console.log(result) ``` @@ -437,10 +445,10 @@ const scores = [ { name: 'Mathias', score: 80 }, { name: 'Elias', score: 50 }, { name: 'Martha', score: 85 }, - { name: 'John', score: 100 } + { name: 'John', score: 100 }, ] -const score = scores.find(user => { +const score = scores.find((user) => { return user.score > 80 }) console.log(score) @@ -458,10 +466,10 @@ _findIndex_: Return the position of the first element which satisfies the condit const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook'] const ages = [24, 22, 25, 32, 35, 18] -const result = names.findIndex(name => name.length > 7) +const result = names.findIndex((name) => name.length > 7) console.log(result) // 0 -const age = ages.findIndex(age => age < 20) +const age = ages.findIndex((age) => age < 20) console.log(age) // 5 ``` @@ -473,7 +481,7 @@ _some_: Check if some of the elements are similar in one aspect. It returns bool const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook'] const bools = [true, true, true, true] -const areSomeTrue = bools.some(b => { +const areSomeTrue = bools.some((b) => { return b === true }) @@ -481,11 +489,10 @@ console.log(areSomeTrue) //true ``` ```js -const areAllStr = names.some(name => typeof name === 'number') +const areAllStr = names.some((name) => typeof name === 'number') console.log(areAllStr) // false ``` - ### sort _sort_: The sort methods arranges the array elements either ascending or descending order. By default, the **_sort()_** method sorts values as strings.This works well for string array items but not for numbers. If number values are sorted as strings and it give us wrong result. Sort method modify the original array. It is recommended to copy the original data before you start using _sort_ method. @@ -506,13 +513,13 @@ As you can see in the example below, 100 came first after sorted in ascending or const numbers = [9.81, 3.14, 100, 37] // Using sort method to sort number items provide a wrong result. see below console.log(numbers.sort()) //[100, 3.14, 37, 9.81] -numbers.sort(function(a, b) { +numbers.sort(function (a, b) { return a - b }) console.log(numbers) // [3.14, 9.81, 37, 100] -numbers.sort(function(a, b) { +numbers.sort(function (a, b) { return b - a }) console.log(numbers) //[100, 37, 9.81, 3.14] @@ -523,7 +530,7 @@ console.log(numbers) //[100, 37, 9.81, 3.14] When ever we sort objects in an array. We use the object key to compare. Lets see the example below. ```js -objArr.sort(function(a, b) { +objArr.sort(function (a, b) { if (a.key < b.key) return -1 if (a.key > b.key) return 1 return 0 @@ -531,7 +538,7 @@ objArr.sort(function(a, b) { // or -objArr.sort(function(a, b) { +objArr.sort(function (a, b) { if (a['key'] < b['key']) return -1 if (a['key'] > b['key']) return 1 return 0 @@ -541,7 +548,7 @@ const users = [ { name: 'Asabeneh', age: 150 }, { name: 'Brook', age: 50 }, { name: 'Eyo', age: 100 }, - { name: 'Elias', age: 22 } + { name: 'Elias', age: 22 }, ] users.sort((a, b) => { if (a.age < b.age) return -1 @@ -568,7 +575,7 @@ const products = [ { product: 'potato', price: ' ' }, { product: 'avocado', price: 8 }, { product: 'coffee', price: 10 }, - { product: 'tea', price: '' } + { product: 'tea', price: '' }, ] ``` @@ -587,17 +594,17 @@ const products = [ 13. Use **_filter_** to filter out countries containing six letters and more in the country array. 14. Use **_filter_** to filter out country start with 'E'; 15. Use **_filter_** to filter out only prices with values. -18. Declare a function called getStringLists which takes an array as a parameter and then returns an array only with string items. -19. Use **_reduce_** to sum all the numbers in the numbers array. -20. Use **_reduce_** to concatenate all the countries and to produce this sentence: **_Estonia, Finland, Sweden, Denmark, Norway, and IceLand are north European countries_** -21. Explain the difference between **_some_** and **_every_** -22. Use **_some_** to check if some names' length greater than seven in names array -23. Use **_every_** to check if all the countries contain the word land -24. Explain the difference between **_find_** and **_findIndex_**. -25. Use **_find_** to find the first country containing only six letters in the countries array -26. Use **_findIndex_** to find the position of the first country containing only six letters in the countries array -27. Use **_findIndex_** to find the position of **_Norway_** if it doesn't exist in the array you will get -1. -28. Use **_findIndex_** to find the position of **_Russia_** if it doesn't exist in the array you will get -1. +16. Declare a function called getStringLists which takes an array as a parameter and then returns an array only with string items. +17. Use **_reduce_** to sum all the numbers in the numbers array. +18. Use **_reduce_** to concatenate all the countries and to produce this sentence: **_Estonia, Finland, Sweden, Denmark, Norway, and IceLand are north European countries_** +19. Explain the difference between **_some_** and **_every_** +20. Use **_some_** to check if some names' length greater than seven in names array +21. Use **_every_** to check if all the countries contain the word land +22. Explain the difference between **_find_** and **_findIndex_**. +23. Use **_find_** to find the first country containing only six letters in the countries array +24. Use **_findIndex_** to find the position of the first country containing only six letters in the countries array +25. Use **_findIndex_** to find the position of **_Norway_** if it doesn't exist in the array you will get -1. +26. Use **_findIndex_** to find the position of **_Russia_** if it doesn't exist in the array you will get -1. ### Exercises: Level 2 @@ -614,91 +621,94 @@ const products = [ 1. Use the countries information, in the data folder. Sort countries by name, by capital, by population 1. \*\*\* Find the 10 most spoken languages: - ````js - // Your output should look like this - console.log(mostSpokenLanguages(countries, 10)) - [(91, 'English'), - (45, 'French'), - (25, 'Arabic'), - (24, 'Spanish'), - (9, 'Russian'), - (9, 'Portuguese'), - (8, 'Dutch'), - (7, 'German'), - (5, 'Chinese'), - (4, 'Swahili'), - (4, 'Serbian')] - - // Your output should look like this - console.log(mostSpokenLanguages(countries, 3)) - [ - (91, 'English'), - (45, 'French'), - (25, 'Arabic') - ]``` - - ```` - -1. \*\*\* Use countries_data.js file create a function which create the ten most populated countries - - ````js - console.log(mostPopulatedCountries(countries, 10)) - - [ - {country: 'China', population: 1377422166}, - {country: 'India', population: 1295210000}, - {country: 'United States of America', population: 323947000}, - {country: 'Indonesia', population: 258705000}, - {country: 'Brazil', population: 206135893}, - {country: 'Pakistan', population: 194125062}, - {country: 'Nigeria', population: 186988000}, - {country: 'Bangladesh', population: 161006790}, - {country: 'Russian Federation', population: 146599183}, - {country: 'Japan', population: 126960000} - ] - - console.log(mostPopulatedCountries(countries, 3)) - [ - {country: 'China', population: 1377422166}, - {country: 'India', population: 1295210000}, - {country: 'United States of America', population: 323947000} - ] - ``` - -1. \*\*\* 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 an object called statistics and create all the functions which do statistical calculations as method for the statistics object. Check the output below. - - ```js - const 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 - 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 + // Your output should look like this + console.log(mostSpokenLanguages(countries, 10)) + [ + {country: 'English',count:91}, + {country: 'French',count:45}, + {country: 'Arabic',count:25}, + {country: 'Spanish',count:24}, + {country:'Russian',count:9}, + {country:'Portuguese', count:9}, + {country:'Dutch',count:8}, + {country:'German',count:7}, + {country:'Chinese',count:5}, + {country:'Swahili',count:4} + ] + + // Your output should look like this + console.log(mostSpokenLanguages(countries, 3)) + [ + {country: 'English',count: 91}, + {country: 'French',count: 45}, + {country: 'Arabic',count: 25}, + ]``` + + ```` + +2. \*\*\* Use countries_data.js file create a function which create the ten most populated countries + + ````js + console.log(mostPopulatedCountries(countries, 10)) + + [ + {country: 'China', population: 1377422166}, + {country: 'India', population: 1295210000}, + {country: 'United States of America', population: 323947000}, + {country: 'Indonesia', population: 258705000}, + {country: 'Brazil', population: 206135893}, + {country: 'Pakistan', population: 194125062}, + {country: 'Nigeria', population: 186988000}, + {country: 'Bangladesh', population: 161006790}, + {country: 'Russian Federation', population: 146599183}, + {country: 'Japan', population: 126960000} + ] + + console.log(mostPopulatedCountries(countries, 3)) + [ + {country: 'China', population: 1377422166}, + {country: 'India', population: 1295210000}, + {country: 'United States of America', population: 323947000} + ] + ``` + + ```` + +3. \*\*\* 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 an object called statistics and create all the functions which do statistical calculations as method for the statistics object. Check the output below. + + ```js + const 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 + 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)] + ``` πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 8](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/08_Day/08_day_objects.md) | [Day 10 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/10_Day/10_day_Set_and_Map.md) +[<< Day 8](../08_Day_Objects/08_day_objects.md) | [Day 10 >>](../10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md) diff --git a/09_Day/09_day_starter/data/countries_data.js b/09_Day_Higher_order_functions/09_day_starter/data/countries_data.js similarity index 100% rename from 09_Day/09_day_starter/data/countries_data.js rename to 09_Day_Higher_order_functions/09_day_starter/data/countries_data.js diff --git a/09_Day/09_day_starter/index.html b/09_Day_Higher_order_functions/09_day_starter/index.html similarity index 100% rename from 09_Day/09_day_starter/index.html rename to 09_Day_Higher_order_functions/09_day_starter/index.html diff --git a/09_Day/09_day_starter/scripts/main.js b/09_Day_Higher_order_functions/09_day_starter/scripts/main.js similarity index 100% rename from 09_Day/09_day_starter/scripts/main.js rename to 09_Day_Higher_order_functions/09_day_starter/scripts/main.js diff --git a/10_Day/10_day_Set_and_Map.md b/10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md similarity index 84% rename from 10_Day/10_day_Set_and_Map.md rename to 10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md index 65067c9a8..6d0064cc2 100644 --- a/10_Day/10_day_Set_and_Map.md +++ b/10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Sets and Maps

@@ -7,13 +7,14 @@ Twitter Follow - Author: - Asabeneh Yetayeh
- January, 2020 -
+Author: +Asabeneh Yetayeh
+ January, 2020 +
+
-[<< Day 9](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/09_Day/09_day_higher_order_functions.md) | [Day 11>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/11_Day/11_day_destructuring_and_spread.md) +[<< 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) ![Day 10](../images/banners/day_1_10.png) @@ -43,7 +44,7 @@ ## Set -Set is a collection a collection of elements. Set can only contains unique elements. +Set is a collection of elements. Set can only contains unique elements. Lets see how to create a set ### Creating an empty set @@ -67,7 +68,7 @@ const languages = [ 'French', 'Spanish', 'English', - 'French' + 'French', ] const setOfLangauges = new Set(languages) @@ -88,7 +89,7 @@ const languages = [ 'French', 'Spanish', 'English', - 'French' + 'French', ] const setOfLangauges = new Set(languages) @@ -183,7 +184,7 @@ const languages = [ 'French', 'Spanish', 'English', - 'French' + 'French', ] const langSet = new Set(languages) console.log(langSet) // Set(4)Β {"English", "Finnish", "French", "Spanish"} @@ -193,7 +194,7 @@ const counts = [] const count = {} for (const l of langSet) { - const filteredLang = languages.filter(lng => lng === l) + const filteredLang = languages.filter((lng) => lng === l) console.log(filteredLang) // ["English", "English", "English"] counts.push({ lang: l, count: filteredLang.length }) } @@ -201,11 +202,11 @@ console.log(counts) ``` ```js -[ +;[ { lang: 'English', count: 3 }, { lang: 'Finnish', count: 1 }, { lang: 'French', count: 2 }, - { lang: 'Spanish', count: 1 } + { lang: 'Spanish', count: 1 }, ] ``` @@ -254,7 +255,7 @@ let b = [3, 4, 5, 6] let A = new Set(a) let B = new Set(b) -let c = a.filter(num => B.has(num)) +let c = a.filter((num) => B.has(num)) let C = new Set(c) console.log(C) @@ -276,7 +277,7 @@ let b = [3, 4, 5, 6] let A = new Set(a) let B = new Set(b) -let c = a.filter(num => !B.has(num)) +let c = a.filter((num) => !B.has(num)) let C = new Set(c) console.log(C) @@ -306,7 +307,7 @@ Map(0)Β {} countries = [ ['Finland', 'Helsinki'], ['Sweden', 'Stockholm'], - ['Norway', 'Oslo'] + ['Norway', 'Oslo'], ] const map = new Map(countries) console.log(map) @@ -347,7 +348,7 @@ Helsinki ### Checking key in Map -Check if a key exist in a map using *has* method. It returns *true* or *false*. +Check if a key exist in a map using _has_ method. It returns _true_ or _false_. ```js console.log(countriesMap.has('Finland')) @@ -414,32 +415,37 @@ const countries = ['Finland', 'Sweden', 'Norway'] 1. \*\*\* Use the countries data to find the 10 most spoken languages: - ````js + ```js // Your output should look like this - console.log(mostSpokenLanguages(countries, 10)) - [ - {'English':91}, - {'French':45}, - {'Arabic':25}, - {'Spanish':24}, - {'Russian':9}, - {'Portuguese':9}, - {'Dutch':8}, - {'German':7}, - {'Chinese':5}, - {'Swahili':4}, - {'Serbian':4}] + console.log(mostSpokenLanguages(countries, 10))[ + ({ English: 91 }, + { French: 45 }, + { Arabic: 25 }, + { Spanish: 24 }, + { Russian: 9 }, + { Portuguese: 9 }, + { Dutch: 8 }, + { German: 7 }, + { Chinese: 5 }, + { Swahili: 4 }, + { Serbian: 4 }) + ] // 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](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/09_Day/09_day_higher_order_functions.md) | [Day 11>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/11_Day/11_day_destructuring_and_spread.md) + +[<< 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) +``` diff --git a/10_Day/10_day_starter/data/countries_data.js b/10_Day_Sets_and_Maps/10_day_starter/data/countries_data.js similarity index 100% rename from 10_Day/10_day_starter/data/countries_data.js rename to 10_Day_Sets_and_Maps/10_day_starter/data/countries_data.js diff --git a/10_Day/10_day_starter/index.html b/10_Day_Sets_and_Maps/10_day_starter/index.html similarity index 100% rename from 10_Day/10_day_starter/index.html rename to 10_Day_Sets_and_Maps/10_day_starter/index.html diff --git a/10_Day/10_day_starter/scripts/main.js b/10_Day_Sets_and_Maps/10_day_starter/scripts/main.js similarity index 100% rename from 10_Day/10_day_starter/scripts/main.js rename to 10_Day_Sets_and_Maps/10_day_starter/scripts/main.js diff --git a/11_Day/11_day_destructuring_and_spread.md b/11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md similarity index 96% rename from 11_Day/11_day_destructuring_and_spread.md rename to 11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md index 75e8d4ce6..5f0e896c5 100644 --- a/11_Day/11_day_destructuring_and_spread.md +++ b/11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Destructuring and Spreading

@@ -13,7 +13,7 @@
-[<< Day 10](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/10_Day/10_day_Set_and_Map.md) | [Day 12>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/12_Day/12_day_regular_expressions.md) +[<< Day 10](../10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md) | [Day 12>>](../12_Day_Regular_expressions/12_day_regular_expressions.md) ![Day 11](../images/banners/day_1_11.png) @@ -57,7 +57,7 @@ Destructuring is a way to unpack arrays, and objects and assigning to a distinct ```js const names = ['Asabeneh', 'Brook', 'David', 'John'] - let [firstPerson, secondPerson, ThirdPerson, fourth Person] = names + let [firstPerson, secondPerson, thirdPerson, fourth Person] = names console.log(firstName, secondPerson,thirdPerson, fourthPerson) ``` @@ -108,7 +108,7 @@ If we like to skip on of the values in the array we use additional comma. The co ```js const names = ['Asabeneh', 'Brook', 'David', 'John'] - let [, secondPerson, , fourth Person] = name // first and third person is omitted + let [, secondPerson, , fourthPerson] = name // first and third person is omitted console.log(secondPerson, fourthPerson) ``` @@ -695,4 +695,4 @@ const users = [ ``` πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 10](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/10_Day/10_day_Set_and_Map.md) | [Day 12>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/12_Day/12_day_regular_expressions.md) \ No newline at end of file +[<< Day 10](../10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md) | [Day 12>>](../12_Day_Regular_expressions/12_day_regular_expressions.md) \ No newline at end of file diff --git a/11_Day/11_day_starter/data/countries_data.js b/11_Day_Destructuring_and_spreading/11_day_starter/data/countries_data.js similarity index 100% rename from 11_Day/11_day_starter/data/countries_data.js rename to 11_Day_Destructuring_and_spreading/11_day_starter/data/countries_data.js diff --git a/11_Day/11_day_starter/index.html b/11_Day_Destructuring_and_spreading/11_day_starter/index.html similarity index 100% rename from 11_Day/11_day_starter/index.html rename to 11_Day_Destructuring_and_spreading/11_day_starter/index.html diff --git a/11_Day/11_day_starter/scripts/main.js b/11_Day_Destructuring_and_spreading/11_day_starter/scripts/main.js similarity index 100% rename from 11_Day/11_day_starter/scripts/main.js rename to 11_Day_Destructuring_and_spreading/11_day_starter/scripts/main.js diff --git a/12_Day/12_day_regular_expressions.md b/12_Day_Regular_expressions/12_day_regular_expressions.md similarity index 95% rename from 12_Day/12_day_regular_expressions.md rename to 12_Day_Regular_expressions/12_day_regular_expressions.md index 30c1faaff..99d85f0ff 100644 --- a/12_Day/12_day_regular_expressions.md +++ b/12_Day_Regular_expressions/12_day_regular_expressions.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Regular Expressions

@@ -13,31 +13,31 @@
-[<< Day 11](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/11_Day/11_day_destructuring_and_spread.md) | [Day 13>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/13_Day/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) ![Thirty Days Of JavaScript](../images/banners/day_1_12.png) -- [πŸ“˜ Day 12](#%f0%9f%93%98-day-12) +- [πŸ“˜ Day 12](#-day-12) - [Regular Expressions](#regular-expressions) - - [RegExp parameters](#regex-parameters) + - [RegExp parameters](#regexp-parameters) - [Pattern](#pattern) - [Flags](#flags) - - [Creating a pattern with RegExp Constructor](#creating-a-pattern-with-regex-constructor) - - [Creating a pattern without RegExp Constructor](#creating-a-pattern-without-regex-constructor) - - [RegExpp Object Methods](#regexp-object-methods) + - [Creating a pattern with RegExp Constructor](#creating-a-pattern-with-regexp-constructor) + - [Creating a pattern without RegExp Constructor](#creating-a-pattern-without-regexp-constructor) + - [RegExpp Object Methods](#regexpp-object-methods) - [Testing for a match](#testing-for-a-match) - [Array containing all of the match](#array-containing-all-of-the-match) - [Replacing a substring](#replacing-a-substring) - [Square Bracket](#square-bracket) - - [Escape character(\\) in RegExp](#escape-character-in-regex) + - [Escape character(\\) in RegExp](#escape-character-in-regexp) - [One or more times(+)](#one-or-more-times) - [Period(.)](#period) - [Zero or more times(*)](#zero-or-more-times) - [Zero or one times(?)](#zero-or-one-times) - - [Quantifier in RegExp](#quantifier-in-regex) - - [Cart ^](#cart) + - [Quantifier in RegExp](#quantifier-in-regexp) + - [Cart ^](#cart-) - [Exact match](#exact-match) - - [πŸ’» Exercises](#%f0%9f%92%bb-exercises) + - [πŸ’» Exercises](#-exercises) - [Exercises: Level 1](#exercises-level-1) - [Exercises: Level 2](#exercises-level-2) - [Exercises: Level 3](#exercises-level-3) @@ -521,4 +521,4 @@ distance = 12 πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 11](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/11_Day/11_day_destructuring_and_spread.md) | [Day 13>>](#) +[<< 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) diff --git a/12_Day/12_day_starter/data/countries_data.js b/12_Day_Regular_expressions/12_day_starter/data/countries_data.js similarity index 100% rename from 12_Day/12_day_starter/data/countries_data.js rename to 12_Day_Regular_expressions/12_day_starter/data/countries_data.js diff --git a/12_Day/12_day_starter/index.html b/12_Day_Regular_expressions/12_day_starter/index.html similarity index 100% rename from 12_Day/12_day_starter/index.html rename to 12_Day_Regular_expressions/12_day_starter/index.html diff --git a/12_Day/12_day_starter/scripts/main.js b/12_Day_Regular_expressions/12_day_starter/scripts/main.js similarity index 100% rename from 12_Day/12_day_starter/scripts/main.js rename to 12_Day_Regular_expressions/12_day_starter/scripts/main.js diff --git a/13_Day/13_day_console_object_methods.md b/13_Day_Console_object_methods/13_day_console_object_methods.md similarity index 95% rename from 13_Day/13_day_console_object_methods.md rename to 13_Day_Console_object_methods/13_day_console_object_methods.md index 01ba34941..f17cf293b 100644 --- a/13_Day/13_day_console_object_methods.md +++ b/13_Day_Console_object_methods/13_day_console_object_methods.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Console Object Methods

@@ -14,7 +14,7 @@
-[<< Day 12](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/12_Day/12_day_regular_expressions.md) | [Day 14>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/14_Day/14_day_error_handling.md) +[<< Day 12](../12_Day_Regular_expressions/12_day_regular_expressions.md) | [Day 14>>](../14_Day_Error_handling/14_day_error_handling.md) ![Thirty Days Of JavaScript](../images/banners/day_1_13.png) @@ -355,4 +355,4 @@ The console.clear() cleans the browser console. πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 12](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/12_Day/12_day_regular_expressions.md) | [Day 14>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/14_Day/14_day_error_handling.md) +[<< Day 12](../12_Day_Regular_expressions/12_day_regular_expressions.md) | [Day 14>>](../14_Day_Error_handling/14_day_error_handling.md) diff --git a/13_Day/13_day_starter/data/countries_data.js b/13_Day_Console_object_methods/13_day_starter/data/countries_data.js similarity index 100% rename from 13_Day/13_day_starter/data/countries_data.js rename to 13_Day_Console_object_methods/13_day_starter/data/countries_data.js diff --git a/13_Day/13_day_starter/index.html b/13_Day_Console_object_methods/13_day_starter/index.html similarity index 100% rename from 13_Day/13_day_starter/index.html rename to 13_Day_Console_object_methods/13_day_starter/index.html diff --git a/13_Day/13_day_starter/scripts/main.js b/13_Day_Console_object_methods/13_day_starter/scripts/main.js similarity index 100% rename from 13_Day/13_day_starter/scripts/main.js rename to 13_Day_Console_object_methods/13_day_starter/scripts/main.js diff --git a/14_Day/14_day_error_handling.md b/14_Day_Error_handling/14_day_error_handling.md similarity index 91% rename from 14_Day/14_day_error_handling.md rename to 14_Day_Error_handling/14_day_error_handling.md index e43148647..69cb0c029 100644 --- a/14_Day/14_day_error_handling.md +++ b/14_Day_Error_handling/14_day_error_handling.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Error handling

@@ -14,7 +14,7 @@
-[<< Day 13](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/13_Day/13_day_console_object_methods.md) | [Day 15>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/15_Day/15_day_classes.md) +[<< Day 13](../13_Day_Console_object_methods/13_day_console_object_methods.md) | [Day 15>>](../15_Day_Classes/15_day_classes.md) ![Thirty Days Of JavaScript](../images/banners/day_1_14.png) @@ -80,7 +80,7 @@ try { ```sh ReferenceError: fistName is not defined at :4:20 -In any case I will be executed +In any case it will be executed ``` The catch block take a parameter. It is common to pass e, err or error as a parameter to the catch block. This parameter is an object and it has name and message keys. Lets use the name and message. @@ -190,4 +190,4 @@ Practice πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 13](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/13_Day/13_day_console_object_methods.md) | [Day 15>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/15_Day/15_day_classes.md) +[<< Day 13](../13_Day_Console_object_methods/13_day_console_object_methods.md) | [Day 15>>](../15_Day_Classes/15_day_classes.md) diff --git a/14_Day/14_day_starter/data/countries_data.js b/14_Day_Error_handling/14_day_starter/data/countries_data.js similarity index 100% rename from 14_Day/14_day_starter/data/countries_data.js rename to 14_Day_Error_handling/14_day_starter/data/countries_data.js diff --git a/14_Day/14_day_starter/index.html b/14_Day_Error_handling/14_day_starter/index.html similarity index 100% rename from 14_Day/14_day_starter/index.html rename to 14_Day_Error_handling/14_day_starter/index.html diff --git a/14_Day/14_day_starter/scripts/main.js b/14_Day_Error_handling/14_day_starter/scripts/main.js similarity index 100% rename from 14_Day/14_day_starter/scripts/main.js rename to 14_Day_Error_handling/14_day_starter/scripts/main.js diff --git a/15_Day/15_day_classes.md b/15_Day_Classes/15_day_classes.md similarity index 98% rename from 15_Day/15_day_classes.md rename to 15_Day_Classes/15_day_classes.md index 400d03d02..7b4632895 100644 --- a/15_Day/15_day_classes.md +++ b/15_Day_Classes/15_day_classes.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Classes

@@ -14,7 +14,7 @@
-[<< Day 14](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/14_Day/14_day_error_handling.md) | [Day 16>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/16_Day/16_day_json.md) +[<< Day 14](../14_Day_Error_handling/14_day_error_handling.md) | [Day 16>>](../16_Day_JSON/16_day_json.md) ![Thirty Days Of JavaScript](../images/banners/day_1_15.png) @@ -712,4 +712,4 @@ Frequency Distribution: [(20.0, 26), (16.0, 27), (12.0, 32), (8.0, 37), (8.0, 34 πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 14](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/14_Day/14_day_error_handling.md) | [Day 16>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/16_Day/16_day_json.md) +[<< Day 14](../14_Day_Error_handling/14_day_error_handling.md) | [Day 16>>](../16_Day_JSON/16_day_json.md) diff --git a/15_Day/15_day_starter/data/countries_data.js b/15_Day_Classes/15_day_starter/data/countries_data.js similarity index 100% rename from 15_Day/15_day_starter/data/countries_data.js rename to 15_Day_Classes/15_day_starter/data/countries_data.js diff --git a/15_Day/15_day_starter/index.html b/15_Day_Classes/15_day_starter/index.html similarity index 100% rename from 15_Day/15_day_starter/index.html rename to 15_Day_Classes/15_day_starter/index.html diff --git a/15_Day/15_day_starter/scripts/main.js b/15_Day_Classes/15_day_starter/scripts/main.js similarity index 100% rename from 15_Day/15_day_starter/scripts/main.js rename to 15_Day_Classes/15_day_starter/scripts/main.js diff --git a/16_Day/16_day_json.md b/16_Day_JSON/16_day_json.md similarity index 96% rename from 16_Day/16_day_json.md rename to 16_Day_JSON/16_day_json.md index 41c38e96a..3cdfb406a 100644 --- a/16_Day/16_day_json.md +++ b/16_Day_JSON/16_day_json.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: JSON

@@ -14,7 +14,7 @@
-[<< Day 15](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/15_Day/15_day_classes.md) | [Day 17 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/17_Day/17_day_web_storage.md) +[<< Day 15](../15_Day_Classes/15_day_classes.md) | [Day 17 >>](../17_Day_Web_storages/17_day_web_storages.md) ![Thirty Days Of JavaScript](../images/banners/day_1_16.png) @@ -594,4 +594,4 @@ const txt = `{ πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 15](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/15_Day/15_day_classes.md) | [Day 17 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/17_Day/17_day_web_storage.md) +[<< Day 15](../15_Day_Classes/15_day_classes.md) | [Day 17 >>](../17_Day_Web_storages/17_day_web_storages.md) diff --git a/16_Day/16_day_starter/data/countries_data.js b/16_Day_JSON/16_day_starter/data/countries_data.js similarity index 100% rename from 16_Day/16_day_starter/data/countries_data.js rename to 16_Day_JSON/16_day_starter/data/countries_data.js diff --git a/16_Day/16_day_starter/index.html b/16_Day_JSON/16_day_starter/index.html similarity index 100% rename from 16_Day/16_day_starter/index.html rename to 16_Day_JSON/16_day_starter/index.html diff --git a/16_Day/16_day_starter/scripts/main.js b/16_Day_JSON/16_day_starter/scripts/main.js similarity index 100% rename from 16_Day/16_day_starter/scripts/main.js rename to 16_Day_JSON/16_day_starter/scripts/main.js diff --git a/17_Day/17_day_starter/data/countries_data.js b/17_Day_Web_storages/17_day_starter/data/countries_data.js similarity index 100% rename from 17_Day/17_day_starter/data/countries_data.js rename to 17_Day_Web_storages/17_day_starter/data/countries_data.js diff --git a/17_Day/17_day_starter/index.html b/17_Day_Web_storages/17_day_starter/index.html similarity index 100% rename from 17_Day/17_day_starter/index.html rename to 17_Day_Web_storages/17_day_starter/index.html diff --git a/17_Day/17_day_starter/scripts/main.js b/17_Day_Web_storages/17_day_starter/scripts/main.js similarity index 100% rename from 17_Day/17_day_starter/scripts/main.js rename to 17_Day_Web_storages/17_day_starter/scripts/main.js diff --git a/17_Day/17_day_web_storage.md b/17_Day_Web_storages/17_day_web_storages.md similarity index 95% rename from 17_Day/17_day_web_storage.md rename to 17_Day_Web_storages/17_day_web_storages.md index c5c1a2a43..f10d14d98 100644 --- a/17_Day/17_day_web_storage.md +++ b/17_Day_Web_storages/17_day_web_storages.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Web Storages

@@ -14,7 +14,7 @@
-[<< Day 16](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/16_Day/16_day_json.md) | [Day 18 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/18_Day/18_day_promise.md) +[<< Day 16](../16_Day_JSON/16_day_json.md) | [Day 18 >>](../18_Day_Promises/18_day_promises.md) ![Thirty Days Of JavaScript](../images/banners/day_1_17.png) @@ -230,4 +230,4 @@ localStorage.clear() πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 16](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/16_Day/16_day_json.md) | [Day 18 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/18_Day/18_day_promise.md) +[<< Day 16](../16_Day_JSON/16_day_json.md) | [Day 18 >>](../18_Day_Promises/18_day_promises.md) diff --git a/18_Day/18_day_promise.md b/18_Day_Promises/18_day_promises.md similarity index 94% rename from 18_Day/18_day_promise.md rename to 18_Day_Promises/18_day_promises.md index b225573b5..6d7be2af9 100644 --- a/18_Day/18_day_promise.md +++ b/18_Day_Promises/18_day_promises.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Promises

@@ -14,7 +14,7 @@
-[<< Day 17](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/17_Day/17_day_web_storage.md) | [Day 19>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/19_Day/19_day_closure.md) +[<< Day 17](../17_Day_Web_storages/17_day_web_storages.md) | [Day 19>>](../19_Day_Closures/19_day_closures.md) ![Thirty Days Of JavaScript](../images/banners/day_1_18.png) @@ -269,4 +269,4 @@ const catsAPI = 'https://api.thecatapi.com/v1/breeds' πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 17](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/17_Day/17_day_web_storage.md) | [Day 19>>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/19_Day/19_day_closure.md) +[<< Day 17](../17_Day_Web_storages/17_day_web_storages.md) | [Day 19>>](../19_Day_Closures/19_day_closures.md) diff --git a/18_Day/18_day_starter/data/countries_data.js b/18_Day_Promises/18_day_starter/data/countries_data.js similarity index 100% rename from 18_Day/18_day_starter/data/countries_data.js rename to 18_Day_Promises/18_day_starter/data/countries_data.js diff --git a/18_Day/18_day_starter/index.html b/18_Day_Promises/18_day_starter/index.html similarity index 100% rename from 18_Day/18_day_starter/index.html rename to 18_Day_Promises/18_day_starter/index.html diff --git a/18_Day/18_day_starter/scripts/main.js b/18_Day_Promises/18_day_starter/scripts/main.js similarity index 100% rename from 18_Day/18_day_starter/scripts/main.js rename to 18_Day_Promises/18_day_starter/scripts/main.js diff --git a/19_Day/19_day_closure.md b/19_Day_Closures/19_day_closures.md similarity index 84% rename from 19_Day/19_day_closure.md rename to 19_Day_Closures/19_day_closures.md index 6bce73579..4c9601684 100644 --- a/19_Day/19_day_closure.md +++ b/19_Day_Closures/19_day_closures.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Closures

@@ -14,7 +14,7 @@
-[<< Day 18](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/18_Day/18_day_promise.md) | [Day 20 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/20_Day/20_day_writing_clean_code.md) +[<< Day 18](../18_Day_Promises/18_day_promise.md) | [Day 20 >>](../20_Day_Writing_clean_codes/20_day_writing_clean_codes.md) ![Thirty Days Of JavaScript](../images/banners/day_1_19.png) - [Day 19](#day-19) @@ -101,4 +101,4 @@ console.log(innerFuncs.minusOne) πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 18](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/18_Day/18_day_promise.md) | [Day 20 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/20_Day/20_day_writing_clean_code.md) \ No newline at end of file +[<< Day 18](../18_Day_Promises/18_day_promise.md) | [Day 20 >>](../20_Day_Writing_clean_codes/20_day_writing_clean_codes.md) \ No newline at end of file diff --git a/19_Day/19_day_starter/data/countries_data.js b/19_Day_Closures/19_day_starter/data/countries_data.js similarity index 100% rename from 19_Day/19_day_starter/data/countries_data.js rename to 19_Day_Closures/19_day_starter/data/countries_data.js diff --git a/19_Day/19_day_starter/index.html b/19_Day_Closures/19_day_starter/index.html similarity index 100% rename from 19_Day/19_day_starter/index.html rename to 19_Day_Closures/19_day_starter/index.html diff --git a/19_Day/19_day_starter/scripts/main.js b/19_Day_Closures/19_day_starter/scripts/main.js similarity index 100% rename from 19_Day/19_day_starter/scripts/main.js rename to 19_Day_Closures/19_day_starter/scripts/main.js diff --git a/20_Day/20_day_starter/data/countries_data.js b/20_Day_Writing_clean_codes/20_day_starter/data/countries_data.js similarity index 100% rename from 20_Day/20_day_starter/data/countries_data.js rename to 20_Day_Writing_clean_codes/20_day_starter/data/countries_data.js diff --git a/20_Day/20_day_starter/index.html b/20_Day_Writing_clean_codes/20_day_starter/index.html similarity index 100% rename from 20_Day/20_day_starter/index.html rename to 20_Day_Writing_clean_codes/20_day_starter/index.html diff --git a/20_Day/20_day_starter/scripts/main.js b/20_Day_Writing_clean_codes/20_day_starter/scripts/main.js similarity index 100% rename from 20_Day/20_day_starter/scripts/main.js rename to 20_Day_Writing_clean_codes/20_day_starter/scripts/main.js diff --git a/20_Day/20_day_writing_clean_code.md b/20_Day_Writing_clean_codes/20_day_writing_clean_codes.md similarity index 96% rename from 20_Day/20_day_writing_clean_code.md rename to 20_Day_Writing_clean_codes/20_day_writing_clean_codes.md index 40d6f4e3f..50ed23a79 100644 --- a/20_Day/20_day_writing_clean_code.md +++ b/20_Day_Writing_clean_codes/20_day_writing_clean_codes.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Writing Clean Codes

@@ -14,7 +14,7 @@
-[<< Day 19](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/19_Day/19_day_closure.md) | [Day 21 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/21_Day/21_day_dom.md) +[<< Day 19](../19_Day_Closuers/19_day_closures.md) | [Day 21 >>](../21_Day_DOM/21_day_dom.md) ![Thirty Days Of JavaScript](../images/banners/day_1_20.png) - [Day 20](#day-20) @@ -356,4 +356,4 @@ Whatever style guide you follow be consistent. Follow some programming paradigms πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 19](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/19_Day/19_day_closure.md) | [Day 21 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/21_Day/21_day_dom.md) \ No newline at end of file +[<< Day 19](../19_Day_Closuers/19_day_closures.md) | [Day 21 >>](../21_Day_DOM/21_day_dom.md) diff --git a/21_Day/21_day_dom.md b/21_Day_DOM/21_day_dom.md similarity index 97% rename from 21_Day/21_day_dom.md rename to 21_Day_DOM/21_day_dom.md index 211c73f64..57553911e 100644 --- a/21_Day/21_day_dom.md +++ b/21_Day_DOM/21_day_dom.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Document Object Model(DOM)

@@ -14,7 +14,7 @@
-[<< Day 20](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/20_Day/20_day_writing_clean_code.md) | [Day 22 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/22_Day/22_day_dom_day_2.md) +[<< Day 20](../20_Day_Writing_clean_codes/20_day_writing_clean_codes.md) | [Day 22 >>](../22_Day_Manipulating_DOM_object/22_day_manipulating_DOM_object.md) ![Thirty Days Of JavaScript](../images/banners/day_1_21.png) @@ -406,4 +406,4 @@ As you have notice, the properties of css when we use it in JavaScript is going πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[<< Day 20](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/20_Day/20_day_writing_clean_code.md) | [Day 22 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/22_Day/22_day_dom_day_2.md) +[<< Day 20](../20_Day_Writing_clean_codes/20_day_writing_clean_codes.md) | [Day 22 >>](../22_Day_Manipulating_DOM_object/22_day_manipulating_DOM_object.md) diff --git a/21_Day/21_day_starter/dom_getting_elements_project_1.gif b/21_Day_DOM/21_day_starter/dom_getting_elements_project_1.gif similarity index 100% rename from 21_Day/21_day_starter/dom_getting_elements_project_1.gif rename to 21_Day_DOM/21_day_starter/dom_getting_elements_project_1.gif diff --git a/21_Day/21_day_starter/index.html b/21_Day_DOM/21_day_starter/index.html similarity index 100% rename from 21_Day/21_day_starter/index.html rename to 21_Day_DOM/21_day_starter/index.html diff --git a/21_Day/21_day_starter/scripts/main.js b/21_Day_DOM/21_day_starter/scripts/main.js similarity index 100% rename from 21_Day/21_day_starter/scripts/main.js rename to 21_Day_DOM/21_day_starter/scripts/main.js diff --git a/22_Day/22_day_dom_day_2.md b/22_Day_Manipulating_DOM_object/22_day_manipulating_DOM_object.md similarity index 94% rename from 22_Day/22_day_dom_day_2.md rename to 22_Day_Manipulating_DOM_object/22_day_manipulating_DOM_object.md index acf563e30..d9e4ad712 100644 --- a/22_Day/22_day_dom_day_2.md +++ b/22_Day_Manipulating_DOM_object/22_day_manipulating_DOM_object.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Manipulating DOM Object

@@ -14,7 +14,7 @@
-[<< Day 21](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/21_Day/21_day_dom.md) | [Day 23 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/23_Day/23_day_dom_day_3.md) +[<< Day 21](../21_Day_DOM/21_day_dom.md) | [Day 23 >>](../23_Day_Event_listeners/23_day_event_listeners.md) ![Thirty Days Of JavaScript](../images/banners/day_1_22.png) - [Day 22](#day-22) @@ -228,4 +228,4 @@ Check the requirement of this project from both images(jpg and gif). All the dat πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ - [<< Day 21](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/21_Day/21_day_dom.md) | [Day 23 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/23_Day/23_day_dom_day_3.md) \ No newline at end of file +[<< Day 21](../21_Day_DOM/21_day_dom.md) | [Day 23 >>](../23_Day_Event_listeners/23_day_event_listeners.md) \ No newline at end of file diff --git a/22_Day/22_day_starters/design/dom_min_project_challenge_info_day_1.1.gif b/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_min_project_challenge_info_day_1.1.gif similarity index 100% rename from 22_Day/22_day_starters/design/dom_min_project_challenge_info_day_1.1.gif rename to 22_Day_Manipulating_DOM_object/22_day_starters/design/dom_min_project_challenge_info_day_1.1.gif diff --git a/22_Day/22_day_starters/design/dom_min_project_countries_aray_day_2.2.png b/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_min_project_countries_aray_day_2.2.png similarity index 100% rename from 22_Day/22_day_starters/design/dom_min_project_countries_aray_day_2.2.png rename to 22_Day_Manipulating_DOM_object/22_day_starters/design/dom_min_project_countries_aray_day_2.2.png diff --git a/22_Day/22_day_starters/design/dom_min_project_day_number_generators_2.1.png b/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_min_project_day_number_generators_2.1.png similarity index 100% rename from 22_Day/22_day_starters/design/dom_min_project_day_number_generators_2.1.png rename to 22_Day_Manipulating_DOM_object/22_day_starters/design/dom_min_project_day_number_generators_2.1.png diff --git a/22_Day/22_day_starters/design/dom_mini_project_challenge_info_day_2.3.gif b/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_mini_project_challenge_info_day_2.3.gif similarity index 100% rename from 22_Day/22_day_starters/design/dom_mini_project_challenge_info_day_2.3.gif rename to 22_Day_Manipulating_DOM_object/22_day_starters/design/dom_mini_project_challenge_info_day_2.3.gif diff --git a/22_Day/22_day_starters/design/dom_mini_project_challenge_info_day_2.3.png b/22_Day_Manipulating_DOM_object/22_day_starters/design/dom_mini_project_challenge_info_day_2.3.png similarity index 100% rename from 22_Day/22_day_starters/design/dom_mini_project_challenge_info_day_2.3.png rename to 22_Day_Manipulating_DOM_object/22_day_starters/design/dom_mini_project_challenge_info_day_2.3.png diff --git a/22_Day/22_day_starters/project_1/index.html b/22_Day_Manipulating_DOM_object/22_day_starters/project_1/index.html similarity index 100% rename from 22_Day/22_day_starters/project_1/index.html rename to 22_Day_Manipulating_DOM_object/22_day_starters/project_1/index.html diff --git a/22_Day/22_day_starters/project_1/scripts/main.js b/22_Day_Manipulating_DOM_object/22_day_starters/project_1/scripts/main.js similarity index 100% rename from 22_Day/22_day_starters/project_1/scripts/main.js rename to 22_Day_Manipulating_DOM_object/22_day_starters/project_1/scripts/main.js diff --git a/22_Day/22_day_starters/project_2/data/countries.js b/22_Day_Manipulating_DOM_object/22_day_starters/project_2/data/countries.js similarity index 100% rename from 22_Day/22_day_starters/project_2/data/countries.js rename to 22_Day_Manipulating_DOM_object/22_day_starters/project_2/data/countries.js diff --git a/22_Day/22_day_starters/project_2/index.html b/22_Day_Manipulating_DOM_object/22_day_starters/project_2/index.html similarity index 100% rename from 22_Day/22_day_starters/project_2/index.html rename to 22_Day_Manipulating_DOM_object/22_day_starters/project_2/index.html diff --git a/22_Day/22_day_starters/project_2/scripts/main.js b/22_Day_Manipulating_DOM_object/22_day_starters/project_2/scripts/main.js similarity index 100% rename from 22_Day/22_day_starters/project_2/scripts/main.js rename to 22_Day_Manipulating_DOM_object/22_day_starters/project_2/scripts/main.js diff --git a/22_Day/22_day_starters/project_3/data/challenges_info.js b/22_Day_Manipulating_DOM_object/22_day_starters/project_3/data/challenges_info.js similarity index 100% rename from 22_Day/22_day_starters/project_3/data/challenges_info.js rename to 22_Day_Manipulating_DOM_object/22_day_starters/project_3/data/challenges_info.js diff --git a/22_Day/22_day_starters/project_3/index.html b/22_Day_Manipulating_DOM_object/22_day_starters/project_3/index.html similarity index 100% rename from 22_Day/22_day_starters/project_3/index.html rename to 22_Day_Manipulating_DOM_object/22_day_starters/project_3/index.html diff --git a/22_Day/22_day_starters/project_3/scripts/main.js b/22_Day_Manipulating_DOM_object/22_day_starters/project_3/scripts/main.js similarity index 100% rename from 22_Day/22_day_starters/project_3/scripts/main.js rename to 22_Day_Manipulating_DOM_object/22_day_starters/project_3/scripts/main.js diff --git a/23_Day/23_day_dom_day_3.md b/23_Day_Event_listeners/23_day_event_listeners.md similarity index 95% rename from 23_Day/23_day_dom_day_3.md rename to 23_Day_Event_listeners/23_day_event_listeners.md index a5f4c14bd..1100593d0 100644 --- a/23_Day/23_day_dom_day_3.md +++ b/23_Day_Event_listeners/23_day_event_listeners.md @@ -1,5 +1,5 @@
-

30 Days Of JavaScript

+

30 Days Of JavaScript: Event Listeners

@@ -14,7 +14,7 @@
-[<< Day 22](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/22_Day/22_day_dom_day_2.md) | [Day 24 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/24_Day/24_day_dom_day_4.md) +[<< Day 22](../22_Day_Manipulating_DOM_object/22_day_manipulating_DOM_object.md) | [Day 24 >>](../24_Day_Project_solar_system/24_day_project_solar_system.md) ![Thirty Days Of JavaScript](../images/banners/day_1_23.png) @@ -123,7 +123,6 @@ The following is an example of click type event. - - - - - + + + 30DaysOfScript:Internal Script + + + + ``` This is how we write an internal script most of the time. Writing the JavaScript code in the body section is the most preferred option. Open the browser console to see the output from the console.log() ```html - - - 30DaysOfScript:Internal Script - - - - - - + + + 30DaysOfScript:Internal Script + + + + + + ``` Open the browser console to see the output from the console.log() @@ -340,7 +377,7 @@ Open the browser console to see the output from the console.log() ### External Script Similar to the internal script, the external script link can be on the header or body, but it is preferred to put it in the body. -First, we should create an external JavaScript file with .js extension. All files ending with .js extension are JavaScript files. Create a file introduction.js inside your project directory and write the following code and link this .js file at the bottom of the body. +First, we should create an external JavaScript file with .js extension. All files ending with .js extension. All files ending with .js extension are JavaScript files. Create a file named introduction.js inside your project directory and write the following code and link this .js file at the bottom of the body. ```js console.log('Welcome to 30DaysOfJavaScript') @@ -350,37 +387,36 @@ External scripts in the _head_: ```html - - - 30DaysOfJavaScript:External script - - - - - + + + 30DaysOfJavaScript:External script + + + + ``` External scripts in the _body_: ```html - - - 30DaysOfJavaScript:External script - - - //it could be in the header or in the body - // Here is the recommended place to put the external script - - - + + + 30DaysOfJavaScript:External script + + + //it could be in the header or in the body // Here is the recommended place + to put the external script + + + ``` -Open the browser console to see the output from the console.log() +Open the browser console to see the output of the console.log() ### Multiple External Scripts -We can link multiple external JavaScript files to a web page. +We can also link multiple external JavaScript files to a web page. Create a helloworld.js file inside the 30DaysOfJS folder and write the following code. ```js @@ -389,19 +425,18 @@ console.log('Hello, World!') ```html - - - Multiple External Scripts - - - - - - - + + + Multiple External Scripts + + + + + + ``` -*Your main.js file should be below all other scripts*. It is very important to remember this. +_Your main.js file should be below all other scripts_. It is very important to remember this. ![Multiple Script](./images/multiple_script.png) @@ -409,28 +444,27 @@ console.log('Hello, World!') In JavaScript and also other programming languages, there are different kinds of data types. The following are JavaScript primitive data types:_String, Number, Boolean, undefined, Null_, and _Symbol_. -### Number +### Numbers -- Integer: Integer (negative, zero and positive) numbers - Example: - ... -3, -2, -1, 0, 1, 2, 3 ... -- Float: Decimal number - Example - ... -3.5, -2.25, -1.0, 0.0, 1.1, 2.2, 3.5 ... +- Integers: Integer (negative, zero and positive) numbers + Example: + ... -3, -2, -1, 0, 1, 2, 3 ... +- Float-point numbers: Decimal number + Example + ... -3.5, -2.25, -1.0, 0.0, 1.1, 2.2, 3.5 ... -### String +### Strings -A collection of one or more characters under a single quote, double quote, or backtick quote. +A collection of one or more characters between two single quotes, double quotes, or backticks. **Example:** ```js 'Asabeneh' '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 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') ``` ### Booleans @@ -442,8 +476,8 @@ A boolean data type is either a true or false value. **Example:** ```js - true // if the light on ,the value is true - false // if the light off, the value is false +true // if the light on ,the value is true +false // if the light off, the value is false ``` ### Undefined @@ -451,8 +485,8 @@ A boolean data type is either a true or false value. In JavaScript, if we don't assign a value to a variable, the value is undefined. In addition to that, if a function is not returning anything, it returns undefined. ```js -let firstName; -console.log(firstName); //not defined, because it is not assigned to a value yet +let firstName +console.log(firstName) //not defined, because it is not assigned to a value yet ``` ### Null @@ -469,15 +503,15 @@ To check the data type of a certain variable, we use the **typeof** operator. Se ```js 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 +console.log(typeof 5) // number +console.log(typeof true) // boolean +console.log(typeof null) // object type +console.log(typeof undefined) // undefined ``` ## Comments Again -Reminding, that commenting in JavaScript is similar to other programming languages. Comments are important in making your make code more readable. +Remember that commenting in JavaScript is similar to other programming languages. Comments are important in making your code more readable. There are two ways of commenting: - _Single line commenting_ @@ -502,44 +536,44 @@ Multiline commenting: ## Variables -Variables are _containers_ of data. Variables used to _store_ data in a memory location. When a variable is declared, a memory location is reserved. When a variable is assigned to a value (data), the memory space will be filled with that data. To declare a variable, we use _var_, _let_, or _const_ keywords. We will talk more about var, let, and const in detail in other sections (scope). For now, the above explanation is enough. +Variables are _containers_ of data. Variables are used to _store_ data in a memory location. When a variable is declared, a memory location is reserved. When a variable is assigned to a value (data), the memory space will be filled with that data. To declare a variable, we use _var_, _let_, or _const_ keywords. -For a variable that changes at a different time, we use _let_. If the data does not change at all, we use _const_. For example, PI, country name, gravity do no change, and we can use *const*. We will not use var in this challenge and I don't recommend you to use it. It is error prone way of declaring variable it has lots of leak. +For a variable that changes at a different time, we use _let_. If the data does not change at all, we use _const_. For example, PI, country name, gravity do no change, and we can use _const_. We will not use var in this challenge and I don't recommend you to use it. It is error prone way of declaring variable it has lots of leak. We will talk more about var, let, and const in detail in other sections (scope). For now, the above explanation is enough. -A valid JavaScript +A valid JavaScript variable name must follow the following rules: -- A JavaScript variable name should not begin with a number. +- A JavaScript variable name should not begin with a number. - A JavaScript variable name does not allow special characters except dollar sign and underscore. - A JavaScript variable name follows a camelCase convention. - A JavaScript variable name should not have space between words. -The following are valid examples of JavaScript variables. -Valid variables in JavaScript: +The following are examples of valid JavaScript variables. ```js - firstName - lastName - country - city - capitalCity - age - isMarried - - first_name - last_name - is_married - capital_city - - num1 - num_1 - _num_1 - $num1 - year2020 - year_2020 -``` - -camelCase or the first way of declaring is conventional in JavaScript. In this material, we will use camelCase variables. -Invalid variables: +firstName +lastName +country +city +capitalCity +age +isMarried + +first_name +last_name +is_married +capital_city + +num1 +num_1 +_num_1 +$num1 +year2020 +year_2020 +``` + +The first and second variables on the list follows the camelCase convention of declaring in JavaScrip. In this material, we will use camelCase variables. + +Example of invalid variables: ```sh first-name @@ -547,14 +581,14 @@ Invalid variables: num_#_1 ``` -Let us declare variables with different data types. To declare a variable, we need to use let or const keyword before the variable name. Following the variable name, we write an equal sign (assignment operator), and a value. +Let us declare variables with different data types. To declare a variable, we need to use _let_ or _const_ keyword before the variable name. Following the variable name, we write an equal sign (assignment operator), and a value(assigned data). ```js - // Syntax - let nameOfVariable = value +// Syntax +let nameOfVariable = value ``` -**Examples: Variables** +**Examples of declared variables** ```js // Declaring different variables of different data types @@ -574,10 +608,10 @@ Asabeneh Yetayeh Finland Helsinki 100 True ```js // Declaring variables with number values -let age = 100 // age in years -const gravity = 9.81 // earth gravity in m/s2 -const boilingPoint = 100 // water boiling point, temperature in oC -const PI = 3.14 // geometrical constant +let age = 100 // age in years +const gravity = 9.81 // earth gravity in m/s2 +const boilingPoint = 100 // water boiling point, temperature in oC +const PI = 3.14 // geometrical constant console.log(gravity, boilingPoint, PI) ``` @@ -590,40 +624,40 @@ console.log(gravity, boilingPoint, PI) // Variables can also be declaring in one line separated by comma let name = 'Asabeneh', // name of a person job = 'teacher', - live = 'Finland'; -console.log(name, job, live); + live = 'Finland' +console.log(name, job, live) ``` ```sh Asabeneh teacher Finland ``` -When you run the files on 01-Day folder you should get this: +When you run _index.html_ file in the 01-Day folder you should get this: ![Day one](./images/day_1.png) -πŸŒ• You are amazing! You have just completed day 1 challenge and you are on your way to greatness. Now do some exercises for your brain and for your muscle. +πŸŒ• You are amazing! You have just completed day 1 challenge and you are on your way to greatness. Now do some exercises for your brain and muscle. # πŸ’» Day 1: Exercises 1. Write a single line comment which says, _comments can make code readable_ -2. Write another single comment which says, *Welcome to 30DaysOfJavaScript* +2. Write another single comment which says, _Welcome to 30DaysOfJavaScript_ 3. Write a multiline comment which says, _comments can make code readable, easy to reuse_ _and informative_ 4. Create a variable.js file and declare variables and assign string, boolean, undefined and null data types -5. Create datatypes.js file and use the JavaScript ***typeof*** operator to check different data types. Check the data type of each variable +5. Create datatypes.js file and use the JavaScript **_typeof_** operator to check different data types. Check the data type of each variable 6. Declare four variables without assigning values -7. Declare four variables with assigning values +7. Declare four variables with assigned values 8. Declare variables to store your first name, last name, marital status, country and age in multiple lines 9. Declare variables to store your first name, last name, marital status, country and age in a single line 10. Declare two variables _myAge_ and _yourAge_ and assign them initial values and log to the browser console. - ```sh - I am 25 years old. - You are 30 years old. - ``` +```sh +I am 25 years old. +You are 30 years old. +``` πŸŽ‰ CONGRATULATIONS ! πŸŽ‰ -[Day 2 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/02_Day/02_day_data_types.md) +[Day 2 >>](./02_Day_Data_types/02_day_data_types.md)