pull/56/head
Asabeneh 5 years ago
parent 37ba263109
commit 1145e81851

@ -40,6 +40,9 @@
- [String to Float](#string-to-float) - [String to Float](#string-to-float)
- [Float to Int](#float-to-int) - [Float to Int](#float-to-int)
- [💻 Day 2: Exercises](#%f0%9f%92%bb-day-2-exercises) - [💻 Day 2: Exercises](#%f0%9f%92%bb-day-2-exercises)
- [Exercise: Level 1](#exercise-level-1)
- [Exercise: Level 2](#exercise-level-2)
- [Exercises: Level 3](#exercises-level-3)
# 📔 Day 2 # 📔 Day 2
@ -878,6 +881,8 @@ console.log(numInt) // 9
# 💻 Day 2: Exercises # 💻 Day 2: Exercises
## Exercise: Level 1
1. Declare a variable name challenge and assign it to an initial value **'30 Days Of JavaScript'**. 1. Declare a variable name challenge and assign it to an initial value **'30 Days Of JavaScript'**.
2. Print the string on the browser console using __console.log()__ 2. Print the string on the browser console using __console.log()__
3. Print the __length__ of the string on the browser console using _console.log()_ 3. Print the __length__ of the string on the browser console using _console.log()_
@ -885,64 +890,70 @@ console.log(numInt) // 9
5. Change all the string to lowercase letters using __toLowerCase()__ method 5. Change all the string to lowercase letters using __toLowerCase()__ method
6. Cut(slice) out the first word of the string using __substr()__ or __substring()__ method 6. Cut(slice) out the first word of the string using __substr()__ or __substring()__ method
7. Slice out the phrase *Days Of JavaScript* from *30 Days Of JavaScript*. 7. Slice out the phrase *Days Of JavaScript* from *30 Days Of JavaScript*.
8. Use __substr__ to slice out the phase __because because because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__ 8. Check if the string contains a word __Script__ using __includes()__ method
9. Check if the string contains a word __Script__ using __includes()__ method 9. Split the __string__ into __array__ using __split()__ method
10. Split the __string__ into __array__ using __split()__ method 10. Split the string 30 Days Of JavaScript at the space using __split()__ method
11. Split the string 30 Days Of JavaScript at the space using __split()__ method 11. 'Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon' __split__ the string at the comma and change it to an array.
12. 'Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon' __split__ the string at the comma and change it to an array. 12. Change 30 Days Of JavaScript to 30 Days Of Python using __replace()__ method.
13. Change 30 Days Of JavaScript to 30 Days Of Python using __replace()__ method. 13. What is character at index 15 in '30 Days Of JavaScript' string use __charAt()__ method.
14. What is character at index 15 in '30 Days Of JavaScript' string use __charAt()__ method. 14. What is the character code of J in '30 Days Of JavaScript' string using __charCodeAt()__
15. What is the character code of J in '30 Days Of JavaScript' string using __charCodeAt()__ 15. Use __indexOf__ to determine the position of the first occurrence of a in 30 Days Of JavaScript
16. Use __indexOf__ to determine the position of the first occurrence of a in 30 Days Of JavaScript 16. Use __lastIndexOf__ to determine the position of the last occurrence of a in 30 Days Of JavaScript.
17. Use __lastIndexOf__ to determine the position of the last occurrence of a in 30 Days Of JavaScript. 17. Use __indexOf__ to find the position of the first occurrence of the word __because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__
18. Use __indexOf__ to find the position of the first occurrence of the word __because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__ 18. Use __lastIndexOf__ to find the position of the last occurrence of the word __because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__
19. Use __lastIndexOf__ to find the position of the last occurrence of the word __because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__ 19. Use __search__ to find the position of the first occurrence of the word __because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__
20. Use __search__ to find the position of the first occurrence of the word __because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__ 20. Use __trim()__ to remove if there is trailing whitespace at the beginning and the end of a string.E.g ' 30 Days Of JavaScript '.
21. Use __trim()__ to remove if there is trailing whitespace at the beginning and the end of a string.E.g ' 30 Days Of JavaScript '. 21. Use __startsWith()__ method with the string *30 Days Of JavaScript* make the result true
22. Use __startsWith()__ method with the string *30 Days Of JavaScript* make the result true 22. Use __endsWith()__ method with the string *30 Days Of JavaScript* make the result true
23. Use __endsWith()__ method with the string *30 Days Of JavaScript* make the result true 23. Use __match()__ method to find all the as in 30 Days Of JavaScript
24. Use __match()__ method to find all the as in 30 Days Of JavaScript 24. Use __concat()__ and merge '30 Days of' and 'JavaScript' to a single string, '30 Days Of JavaScript'
25. Use __match()__ to count the number all because's in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__ 25. Use __repeat()__ method to print 30 Days Of JavaScript 2 times
26. Use __concat()__ and merge '30 Days of' and 'JavaScript' to a single string, '30 Days Of JavaScript'
27. Use __repeat()__ method to print 30 Days Of JavaScript 2 times ### Exercise: Level 2
28. ** 'Love is the best thing in this world. Some found their love and some are still looking for their love.' Count the number of word love in this sentence.
29. ** Calculate the total annual income of the person by extract the numbers from the following text. 'He earns 5000 euro from salary per month, 10000 euro annual bonus, 15000 euro online courses per month.' 1. Using console.log() print out the following statement.
30. ** Clean the following text and find the most frequent word(hint, use replace and regular express).
```sh
```js The quote 'There is no exercise better for the heart than reaching down and lifting people up.' by John Holmes teaches us to help one another.
const sentence = '%I $am@% a %tea@cher%, &and& I lo%#ve %tea@ching%;. There $is nothing; &as& mo@re rewarding as educa@ting &and& @emp%o@wering peo@ple. ;I found tea@ching m%o@re interesting tha@n any other %jo@bs. %Do@es thi%s mo@tivate yo@u to be a tea@cher!? %Th#is 30#Days&OfJavaScript &is also $the $result of &love& of tea&ching' ```
```
1. Using console.log() print out the following quote by Mother Teresa.
31. Using console.log() print out the following statement.
```sh
```sh "Love is not patronizing and charity isn't about pity, it is about love. Charity and love are the same -- with charity you give love, so don't just give money but reach out your hand instead."
The quote 'There is no exercise better for the heart than reaching down and lifting people up.' by John Holmes teaches us to help to one another. ```
```
1. Check if typeof '10' is exactly equal to 10. If not make it exactly equal.
32. Using console.log() print out the following quote by Mother Teresa. 1. Check if parseFloat('9.8') is equal to 10 if not make it exactly equal with 10.
2. Check if 'on' is found in both python and jargon
```sh 3. _I hope this course is not full of jargon_. Check if _jargon_ is in the sentence.
"Love is not patronizing and charity isn't about pity, it is about love. Charity and love are the same -- with charity you give love, so don't just give money but reach out your hand instead." 4. Generate a random number between 0 and 100 inclusive.
``` 5. Generate a random number between 50 and 100 inclusive.
6. Generate a random number between 0 and 255 inclusive.
33. Check if 'on' is found in both python and jargon 7. Access the 'JavaScript' string characters using a random number.
34. _I hope this course is not full of jargon_. Check if _jargon_ is in the sentence. 8. Use console.log() and escape characters to print the following pattern.
35. Generate a random number between 0 and 100 inclusive.
36. Generate a random number between 50 and 100 inclusive. ```js
37. Generate a random number between 0 and 255 inclusive. 1 1 1 1 1
38. Access the 'JavaScript' string characters using a random number. 2 1 2 4 8
39. Use console.log() and escape characters to print the following pattern. 3 1 3 9 27
4 1 4 16 64
```js 5 1 5 25 125
1 1 1 1 1 ```
2 1 2 4 8
3 1 3 9 27 9. Use __substr__ to slice out the phase __because because because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__
4 1 4 16 64
5 1 5 25 125 ### Exercises: Level 3
```
1. 'Love is the best thing in this world. Some found their love and some are still looking for their love.' Count the number of word love in this sentence.
40. Check if typeof '10' is exactly equal to 10. If not make it exactly equal. 2. Use __match()__ to count the number all because's in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__
41. Check if parseInt('9.8') is equal to 10 if not make it exactly equal with 10. 3. Clean the following text and find the most frequent word(hint, use replace and regular express).
```js
const sentence = '%I $am@% a %tea@cher%, &and& I lo%#ve %te@a@ching%;. The@re $is no@th@ing; &as& mo@re rewarding as educa@ting &and& @emp%o@weri@ng peo@ple. ;I found tea@ching m%o@re interesting tha@n any ot#her %jo@bs. %Do@es thi%s mo@tiv#ate yo@u to be a tea@cher!? %Th#is 30#Days&OfJavaScript &is al@so $the $resu@lt of &love& of tea&ching'
```
4. Calculate the total annual income of the person by extract the numbers from the following text. 'He earns 5000 euro from salary per month, 10000 euro annual bonus, 15000 euro online courses per month.'
🎉 CONGRATULATIONS ! 🎉 🎉 CONGRATULATIONS ! 🎉

@ -46,14 +46,10 @@
- [Getting minutes](#getting-minutes) - [Getting minutes](#getting-minutes)
- [Getting seconds](#getting-seconds) - [Getting seconds](#getting-seconds)
- [Getting time](#getting-time) - [Getting time](#getting-time)
- [💻 Day 3: Exercises](#%f0%9f%92%bb-day-3-exercises) - [💻 Day 3: Exercises](#%f0%9f%92%bb-day-3-exercises)
- [1. Exercises: Data types Part](#1-exercises-data-types-part) - [Exercises: Level 1](#exercises-level-1)
- [2. Exercises: Arithmetic Operators Part](#2-exercises-arithmetic-operators-part) - [Exercises: Level 2](#exercises-level-2)
- [3. Exercises: Booleans Part](#3-exercises-booleans-part) - [Exercises: Level 3](#exercises-level-3)
- [4. Exercises: Comparison Operators](#4-exercises-comparison-operators)
- [5. Exercises: Logical Operators](#5-exercises-logical-operators)
- [6 Ternary Operator](#6-ternary-operator)
- [7. Exercises: Date time Object](#7-exercises-date-time-object)
# 📔 Day 3 # 📔 Day 3
@ -146,6 +142,9 @@ let powerOf = numOne ** numTwo
console.log(sum, diff, mult, div, remainder, powerOf) // 7,1,12,1.33,1, 64 console.log(sum, diff, mult, div, remainder, powerOf) // 7,1,12,1.33,1, 64
```
```js
let PI = 3.14 let PI = 3.14
let radius = 100 // length in meter let radius = 100 // length in meter
@ -476,6 +475,7 @@ console.log(now.getTime()) // 1578092201341, this is the number of seconds passe
```js ```js
const allSeconds = Date.now() // const allSeconds = Date.now() //
console.log(allSeconds) // 1578092201341, this is the number of seconds passed from January 1, 1970 to January 4, 2020 00:56:41 console.log(allSeconds) // 1578092201341, this is the number of seconds passed from January 1, 1970 to January 4, 2020 00:56:41
const timeInSeconds = new Date().getTime() const timeInSeconds = new Date().getTime()
console.log(allSeconds == timeInSeconds) // true console.log(allSeconds == timeInSeconds) // true
``` ```
@ -490,21 +490,60 @@ const month = now.getMonth() + 1 // return month(0 - 11)
const date = now.getDate() // return date (1 - 31) const date = now.getDate() // return date (1 - 31)
const hours = now.getHours() // return number (0 - 23) const hours = now.getHours() // return number (0 - 23)
const minutes = now.getMinutes() // return number (0 -59) const minutes = now.getMinutes() // return number (0 -59)
console.log(`${date}/${month}/${year} ${hours}:${minutes}`) // 4/1/2020 0:56 console.log(`${date}/${month}/${year} ${hours}:${minutes}`) // 4/1/2020 0:56
``` ```
🌕 You have boundless energy. You have just completed day 3 challenges and you are three steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle. 🌕 You have boundless energy. You have just completed day 3 challenges and you are three steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle.
# 💻 Day 3: Exercises ## 💻 Day 3: Exercises
## 1. Exercises: Data types Part ### Exercises: Level 1
1. Declare firstName, lastName, country, city, age, isMarried, year variable and assign value to it and use the typeof operator to check different data types.
2. Check if type of '10' is equal to 10
3. Check if parseInt('9.8') is equal to 10
4. Boolean value is either true or false.
1. Write three JavaScript statement which provide truthy value.
2. Write three JavaScript statement which provide falsy value.
5. Figure out the result of the following comparison expression first without using console.log(). After you decide the result confirm it using console.log()
1. 4 > 3
2. 4 >= 3
3. 4 < 3
4. 4 <= 3
5. 4 == 4
6. 4 === 4
7. 4 != 4
8. 4 !== 4
9. 4 != '4'
10. 4 == '4'
11. 4 === '4'
12. Find the length of python and jargon and make a falsy comparison statement.
6. Figure out the result of the following expressions first without using console.log(). After you decide the result confirm it by using console.log()
1. 4 > 3 && 10 < 12
2. 4 > 3 && 10 > 12
3. 4 > 3 || 10 < 12
4. 4 > 3 || 10 > 12
5. !(4 > 3)
6. !(4 < 3)
7. !(false)
8. !(4 > 3 && 10 < 12)
9. !(4 > 3 && 10 > 12)
10. !(4 === '4')
11. There is no 'on' in both dragon and python
1. Declare firstName, lastName, country, city, age, isMarried, year variable and assign value to it 7. Use the Date object to do the following activities
1. The JavaScript typeof operator uses to check different data types. Check the data type of each variables from question number 1. 1. What is the year today?
1. Check if type of '10' is equal to 10 2. What is the month today as a number?
1. Check if parseInt('9.8') is equal to 10 3. What is the date today?
4. What is the day today as a number?
5. What is the hours now?
6. What is the minutes now?
7. Find out the numbers of seconds elapsed from January 1, 1970 to now.
## 2. Exercises: Arithmetic Operators Part ### Exercises: Level 2
1. Write a script that prompt the user to enter base and height of the triangle and calculate an area of a triangle (area = 0.5 x b x h). 1. Write a script that prompt the user to enter base and height of the triangle and calculate an area of a triangle (area = 0.5 x b x h).
@ -531,75 +570,25 @@ console.log(`${date}/${month}/${year} ${hours}:${minutes}`) // 4/1/2020 0:56
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. 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 enters hours and rate per hour. Calculate pay of the person?
```sh ```sh
Enter hours: 40 Enter hours: 40
Enter rate per hour: 28 Enter rate per hour: 28
Your weekly earning is 1120 Your weekly earning is 1120
``` ```
1. Write a script that prompt the user to enter number of years. Calculate the number of seconds a person can live. Assume some one lives just hundred years
```sh
Enter number of yours you live: 100
You lived 3153600000 seconds.
```
## 3. Exercises: Booleans Part
Boolean value is either true or false.
1. Write three JavaScript statement which provide truthy value.
1. Write three JavaScript statement which provide falsy value.
## 4. Exercises: Comparison Operators
Figure out the result of the following comparison expression first without using console.log(). After you decide the result confirm it using console.log()
1. 4 > 3
1. 4 >= 3
1. 4 < 3
1. 4 <= 3
1. 4 == 4
1. 4 === 4
1. 4 != 4
1. 4 !== 4
1. 4 != '4'
1. 4 == '4'
1. 4 === '4'
Find the length of python and jargon and make a falsy comparison statement.
## 5. Exercises: Logical Operators
1. Figure out the result of the following expressions first without using console.log(). After you decide the result confirm it by using console.log()
1. 4 > 3 && 10 < 12
2. 4 > 3 && 10 > 12
3. 4 > 3 || 10 < 12
4. 4 > 3 || 10 > 12
5. !(4 > 3)
6. !(4 < 3)
7. !(false)
8. !(4 > 3 && 10 < 12)
9. !(4 > 3 && 10 > 12)
10. !(4 === '4')
2. There is no 'on' in both dragon and python
## 6 Ternary Operator
1. If the length of your name is greater than 7 say, your name is long else say your name is short. 1. If the length of your name is greater than 7 say, your name is long else say your name is short.
1. Compare your first name length and your family name length and you should get this output. 1. Compare your first name length and your family name length and you should get this output.
```js ```js
let firstName = 'Asabeneh' let firstName = 'Asabeneh'
let lastName = 'Yetayeh' let lastName = 'Yetayeh'
``` ```
```sh ```sh
//Output Your first name, Asabeneh is longer than your family name, Yetayeh
Your first name, Asabeneh is longer than your family name, Yetayeh ```
```
1. Declare two variables _myAge_ and _yourAge_ and assign them initial values and myAge and yourAge. 1. Declare two variables _myAge_ and _yourAge_ and assign them initial values and myAge and yourAge.
Output:
```js ```js
let myAge = 250 let myAge = 250
@ -607,32 +596,36 @@ Your first name, Asabeneh is longer than your family name, Yetayeh
``` ```
```sh ```sh
//output
I am 225 years older than you. I am 225 years older than you.
``` ```
1. Using prompt get the year the user was born and if the user is 18 or above allow the user to drive if not tell the user to wait a certain amount of years. 1. Using prompt get the year the user was born and if the user is 18 or above allow the user to drive if not tell the user to wait a certain amount of years.
```sh ```sh
// if the age is 25
You are 25. You are old enough to drive Enter birth year: 1995
// if the age is under 18 You are 25. You are old enough to drive
You are 15. You will be allowed to drive after 3 years.
``` Enter birth year: 2005
You are 15. You will be allowed to drive after 3 years.
## 7. Exercises: Date time Object ```
1. What is the year today? 1. Write a script that prompt the user to enter number of years. Calculate the number of seconds a person can live. Assume some one lives just hundred years
1. What is the month today as a number?
1. What is the date today? ```sh
1. What is the day today as a number? Enter number of yours you live: 100
1. What is the hours now? You lived 3153600000 seconds.
1. What is the minutes now? ```
1. Find out the numbers of seconds elapsed from January 1, 1970 to now.
1. Create a human readable time format 1. Create a human readable time format using the Date time object
1. YYY-MM-DD HH:mm:ss 1. YYY-MM-DD HH:mm
2. DD-MM-YYYY HH:mm:ss 2. DD-MM-YYYY HH:mm
3. DD/MM/YYY HH:mm:ss 3. DD/MM/YYY HH:mm
### Exercises: Level 3
1. Create a human readable time format using the Date time object. The hour and the minute should be all 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 ! 🎉 🎉 CONGRATULATIONS ! 🎉

@ -24,7 +24,10 @@
- [if else if else](#if-else-if-else) - [if else if else](#if-else-if-else)
- [Switch](#switch) - [Switch](#switch)
- [Ternary Operators](#ternary-operators) - [Ternary Operators](#ternary-operators)
- [💻 Exercise : Conditionals](#%f0%9f%92%bb-exercise--conditionals) - [💻 Exercises](#%f0%9f%92%bb-exercises)
- [Exercises: Level 1](#exercises-level-1)
- [Exercises: Level 2](#exercises-level-2)
- [Exercises: Level 3](#exercises-level-3)
# 📔 Day 4 # 📔 Day 4
@ -251,7 +254,9 @@ isRaining
🌕 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 a head in to your way to greatness. Now do some exercises for your brain and for your muscle.
# 💻 Exercise : Conditionals ## 💻 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 feedback to wait for the years he supposed to wait for.
@ -284,19 +289,6 @@ isRaining
4 is greater than 3 4 is greater than 3
``` ```
1. Write a code which give grade 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:
- September, October or November, the season is Autumn.
- December, January or February, the season is Winter.
- March, April or May, the season is Spring
- June, July or August, the season is Summer
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 ```sh
@ -307,6 +299,20 @@ isRaining
9 is is an odd number. 9 is is an odd number.
``` ```
### Exercises: Level 2
1. Write a code which can give grade 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:
- September, October or November, the season is Autumn.
- December, January or February, the season is Winter.
- March, April or May, the season is Spring
- June, July or August, the season is Summer
1. Check if a day is weekend day or a working day. Your script will take day as an input. 1. Check if a day is weekend day or a working day. Your script will take day as an input.
```sh ```sh
@ -323,6 +329,8 @@ isRaining
Friday is a work day. Friday is a work day.
``` ```
### Exercises: Level 3
1. Write a program which tells the number days in a month. 1. Write a program which tells the number days in a month.
```sh ```sh
@ -339,7 +347,6 @@ isRaining
February has 28 days. February has 28 days.
``` ```
🎉 CONGRATULATIONS ! 🎉 🎉 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](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)

@ -44,6 +44,9 @@
- [Sorting elements in array](#sorting-elements-in-array) - [Sorting elements in array](#sorting-elements-in-array)
- [Array of arrays](#array-of-arrays) - [Array of arrays](#array-of-arrays)
- [💻 Exercise](#%f0%9f%92%bb-exercise) - [💻 Exercise](#%f0%9f%92%bb-exercise)
- [Exercise: Level 1](#exercise-level-1)
- [Exercise: Level 2](#exercise-level-2)
- [Exercise: Level 3](#exercise-level-3)
# 📔 Day 5 # 📔 Day 5
@ -659,6 +662,8 @@ console.log(arrayOfArray[0]) // [1, 2, 3]
## 💻 Exercise ## 💻 Exercise
### Exercise: Level 1
```js ```js
const countries = [ const countries = [
'Albania', 'Albania',
@ -708,6 +713,9 @@ const webTechs = [
1. Remove the middle IT company or companies from the array 1. Remove the middle IT company or companies from the array
1. Remove the last IT company from the array 1. Remove the last IT company from the array
1. Remove all IT companies 1. Remove all IT companies
### Exercise: Level 2
1. Create a separate countries.js file and store the countries array in to this file, create a separate file web_techs.js ans store the webTechs array in to this file. Access both file in main.js file 1. Create a separate countries.js file and store the countries array in to this file, create a separate file web_techs.js ans store the webTechs array in to this file. Access both file in main.js file
1. First remove all the functions and change the string to array and count the number of words in the array 1. First remove all the functions and change the string to array and count the number of words in the array
@ -720,6 +728,7 @@ const webTechs = [
```sh ```sh
["I", "love", "teaching", "and", "empowering", "people", "I", "teach", "HTML", "CSS", "JS", "React", "Python"] ["I", "love", "teaching", "and", "empowering", "people", "I", "teach", "HTML", "CSS", "JS", "React", "Python"]
13 13
``` ```
@ -748,6 +757,8 @@ const webTechs = [
["HTML", "CSS", "JS", "React", "Redux", "Node", "Express", "MongoDB"] ["HTML", "CSS", "JS", "React", "Redux", "Node", "Express", "MongoDB"]
``` ```
### Exercise: Level 3
1. The following is an array of 10 students ages: 1. The following is an array of 10 students ages:
```js ```js

@ -26,6 +26,9 @@
- [break](#break) - [break](#break)
- [continue](#continue) - [continue](#continue)
- [💻 Exercises:Day 6](#%f0%9f%92%bb-exercisesday-6) - [💻 Exercises:Day 6](#%f0%9f%92%bb-exercisesday-6)
- [Exercises: Level 1](#exercises-level-1)
- [Exercises: Level 2](#exercises-level-2)
- [Exercises: Level 3](#exercises-level-3)
# 📔 Day 6 # 📔 Day 6
@ -214,6 +217,8 @@ content will added soon
## 💻 Exercises:Day 6 ## 💻 Exercises:Day 6
### Exercises: Level 1
```js ```js
const countries = [ const countries = [
'Albania', 'Albania',
@ -319,7 +324,9 @@ content will added soon
5j2khz 5j2khz
``` ```
16. Develop a small script which generate any number of characters random id: ### Exercises: Level 2
1. Develop a small script which generate any number of characters random id:
```sh ```sh
fe3jo1gl124g fe3jo1gl124g
@ -329,31 +336,31 @@ content will added soon
xkqci4utda1lmbelpkm03rba xkqci4utda1lmbelpkm03rba
``` ```
17. Write a script which generates a random hexadecimal number. 1. Write a script which generates a random hexadecimal number.
```sh ```sh
'#ee33df' '#ee33df'
``` ```
18. Write a script which generates a random rgb color number. 1. Write a script which generates a random rgb color number.
```sh ```sh
rgb(240,180,80) rgb(240,180,80)
``` ```
19. Using the above countries array, create the following new array. 1. Using the above countries array, create the following new array.
```sh ```sh
["ALBANIA", "BOLIVIA", "CANADA", "DENMARK", "ETHIOPIA", "FINLAND", "GERMANY", "HUNGARY", "IRELAND", "JAPAN", "KENYA"] ["ALBANIA", "BOLIVIA", "CANADA", "DENMARK", "ETHIOPIA", "FINLAND", "GERMANY", "HUNGARY", "IRELAND", "JAPAN", "KENYA"]
``` ```
20. Using the above countries array, create an array for countries length'. 1. Using the above countries array, create an array for countries length'.
```sh ```sh
[7, 7, 6, 7, 8, 7, 7, 7, 7, 5, 5] [7, 7, 6, 7, 8, 7, 7, 7, 7, 5, 5]
``` ```
21. Use the countries array to create the following array of arrays: 1. Use the countries array to create the following array of arrays:
```sh ```sh
[ [
@ -371,42 +378,41 @@ content will added soon
] ]
``` ```
22. In above countries array, check if there is a country or countries containing the word 'land'. If there are countries containing 'land', print it as array. If there is no country containing the word 'land', print 'These are countries without land'. 1. In above countries array, check if there is a country or countries containing the word 'land'. If there are countries containing 'land', print it as array. If there is no country containing the word 'land', print 'All these are countries without land'.
```sh ```sh
['Finland', 'Iceland'] ['Finland', 'Iceland']
``` ```
23. In above countries array, check if there a country or countries end with a substring 'ia'. If there are countries end with, print it as array. If there is no country containing the word 'land', print 'These are countries ends without ia'. 1. In above countries array, check if there is a country or countries end with a substring 'ia'. If there are countries end with, print it as array. If there is no country containing the word 'ai', print 'These are countries ends without ia'.
```sh ```sh
['Albania', 'Bolivia','Ethiopia'] ['Albania', 'Bolivia','Ethiopia']
``` ```
24. Using the above countries array, find the country containing the biggest number of characters. 1. Using the above countries array, find the country containing the biggest number of characters.
```sh ```sh
Ethiopia Ethiopia
``` ```
25. Using the above countries array, find the country containing only 5 characters. 1. Using the above countries array, find the country containing only 5 characters.
```sh ```sh
['Japan', 'Kenya'] ['Japan', 'Kenya']
``` ```
26. Find the longest word in the webTechs array 1. Find the longest word in the webTechs array
27. Use the webTechs are to create the following array of arrays: 1. Use the webTechs are to create the following array of arrays:
```sh ```sh
[["HTML", 4], ["CSS", 3],["JavaScript", 10],["React", 5],["Redux", 5],["Node", 4],["MongoDB", 7]] [["HTML", 4], ["CSS", 3],["JavaScript", 10],["React", 5],["Redux", 5],["Node", 4],["MongoDB", 7]]
``` ```
28. An application created using MongoDB, Express, React and Node is called a MERN stack. Create the acronym MERN by using the array mernStack 1. An application created using MongoDB, Express, React and Node is called a MERN stack. Create the acronym MERN by using the array mernStack
1. Iterate through the array, ["HTML", "CSS", "JS", "React", "Redux", "Node", "Express", "MongoDB"] using a for loop or for of loop and print out the items.
29. Iterate through the array, ["HTML", "CSS", "JS", "React", "Redux", "Node", "Express", "MongoDB"] using a for loop or for of loop and print out the items. 1. This is a fruit array , ['banana', 'orange', 'mango', 'lemon'] reverse the order using loop without using a reverse method.
30. This is a fruit array , ['banana', 'orange', 'mango', 'lemon'] reverse the order using loop without using a reverse method. 1. Print all the elements of array as shown below.
31. Print all the elements of array as shown below.
```js ```js
const fullStack = [ const fullStack = [
@ -424,15 +430,18 @@ content will added soon
EXPRESS EXPRESS
MONGODB MONGODB
``` ```
32. Copy countries array(Avoid mutation)
33. Arrays are mutable. Create a copy of array which does not modify the original. Sort the copied array and store in a variable sortedCountries ### Exercises: Level 3
34. Sort the webTechs array and mernStack array
35. Extract all the countries contain the word 'land' from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and print it as array 1. Copy countries array(Avoid mutation)
36. Find the country containing the hightest number of characters in the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) 1. Arrays are mutable. Create a copy of array which does not modify the original. Sort the copied array and store in a variable sortedCountries
37. Extract all the countries contain the word 'land' from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and print it as array 1. Sort the webTechs array and mernStack array
38. Extract all the countries containing only four characters from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and print it as array 1. Extract all the countries contain the word 'land' from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and print it as array
39. Extract all the countries containing two or more words from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and print it as array 1. Find the country containing the hightest number of characters in the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js)
40. Reverse the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and capitalize each country and stored it as an array 1. Extract all the countries contain the word 'land' from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and print it as array
1. Extract all the countries containing only four characters from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and print it as array
1. Extract all the countries containing two or more words from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and print it as array
1. Reverse the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js) and capitalize each country and stored it as an array
🎉 CONGRATULATIONS ! 🎉 🎉 CONGRATULATIONS ! 🎉

@ -35,6 +35,9 @@
- [Function with default parameters](#function-with-default-parameters) - [Function with default parameters](#function-with-default-parameters)
- [Function declaration versus Arrow function](#function-declaration-versus-arrow-function) - [Function declaration versus Arrow function](#function-declaration-versus-arrow-function)
- [💻 Exercises](#%f0%9f%92%bb-exercises) - [💻 Exercises](#%f0%9f%92%bb-exercises)
- [Exercises: Level 1](#exercises-level-1)
- [Exercises: Level 2](#exercises-level-2)
- [Exercises: Level 3](#exercises-level-3)
# 📔 Day 7 # 📔 Day 7
@ -504,6 +507,8 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra
## 💻 Exercises ## 💻 Exercises
### Exercises: Level 1
1. Declare a function _fullName_ and it print out your full name. 1. Declare a function _fullName_ and it print out your full name.
2. Declare a function _fullName_ and now it takes firstName, lastName as a parameter and it returns your full - name. 2. Declare a function _fullName_ and now it takes firstName, lastName as a parameter and it returns your full - name.
3. Declare a function _addNumbers_ and it takes two two parameters and it returns sum. 3. Declare a function _addNumbers_ and it takes two two parameters and it returns sum.
@ -534,8 +539,10 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra
0 0
``` ```
16. Linear equation is calculated as follows: _ax + by + c = 0_. Write a function which calculates value of a linear equation, _solveLinEquation_. ### Exercises: Level 2
17. Quadratic equation is calculated as follows: _ax2 + bx + c = 0_. Write a function which calculates value or values of a quadratic equation, _solveQuadEquation_.
1. Linear equation is calculated as follows: _ax + by + c = 0_. Write a function which calculates value of a linear equation, _solveLinEquation_.
1. Quadratic equation is calculated as follows: _ax2 + bx + c = 0_. Write a function which calculates value or values of a quadratic equation, _solveQuadEquation_.
```js ```js
console.log(solveQuadratic()) // {0} console.log(solveQuadratic()) // {0}
@ -546,22 +553,22 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra
console.log(solveQuadratic(1, -1, 0)) //{1, 0} console.log(solveQuadratic(1, -1, 0)) //{1, 0}
``` ```
18. Declare a function name _printArray_. It takes array as a parameter and it prints out each value of the array. 1. Declare a function name _printArray_. It takes array as a parameter and it prints out each value of the array.
19. 11. Write a function name _showDateTime_ which shows time in this format: 08/01/2020 04:08 using the Date object. 1. Write a function name _showDateTime_ which shows time in this format: 08/01/2020 04:08 using the Date object.
```sh ```sh
showDateTime() showDateTime()
08/01/2020 04:08 08/01/2020 04:08
``` ```
20. Declare a function name _swapValues_. This function swaps value of x to y. 1. Declare a function name _swapValues_. This function swaps value of x to y.
```js ```js
swapValues(3, 4) // x => 4, y=>3 swapValues(3, 4) // x => 4, y=>3
swapValues(4, 5) // x = 5, y = 4 swapValues(4, 5) // x = 5, y = 4
``` ```
21. Declare a function name _reverseArray_. It takes array as a parameter and it returns the reverse of the array (don't use method). 1. Declare a function name _reverseArray_. It takes array as a parameter and it returns the reverse of the array (don't use method).
```js ```js
console.log(reverseArray([1, 2, 3, 4, 5])) console.log(reverseArray([1, 2, 3, 4, 5]))
@ -570,13 +577,13 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra
//['C', 'B', 'A'] //['C', 'B', 'A']
``` ```
22. Declare a function name _capitalizeArray_. It takes array as a parameter and it returns the - capitalizedarray. 1. Declare a function name _capitalizeArray_. It takes array as a parameter and it returns the - capitalizedarray.
23. Declare a function name _addItem_. It takes an item parameter and it returns an array after adding the item 1. Declare a function name _addItem_. It takes an item parameter and it returns an array after adding the item
24. Declare a function name _removeItem_. It takes an index parameter and it returns an array after removing an item 1. Declare a function name _removeItem_. It takes an index parameter and it returns an array after removing an item
25. Declare a function name _sumOfNumbers_. It takes a number parameter and it adds all the numbers in that range. 1. Declare a function name _sumOfNumbers_. It takes a number parameter and it adds all the numbers in that range.
26. Declare a function name _sumOfOdds_. It takes a number parameter and it adds all the odd numbers in that - range. 1. Declare a function name _sumOfOdds_. It takes a number parameter and it adds all the odd numbers in that - range.
27. Declare a function name _sumOfEven_. It takes a number parameter and it adds all the even numbers in that - range. 1. Declare a function name _sumOfEven_. It takes a number parameter and it adds all the even numbers in that - range.
28. Declare a function name evensAndOdds . It takes a positive integer as parameter and it counts number of evens and odds in the number. 1. Declare a function name evensAndOdds . It takes a positive integer as parameter and it counts number of evens and odds in the number.
```sh ```sh
evensAndOdds(100); evensAndOdds(100);
@ -584,30 +591,32 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra
The number of evens are 51. The number of evens are 51.
``` ```
29. Write a function which takes any number of arguments and return the sum of the arguments 1. Write a function which takes any number of arguments and return the sum of the arguments
```js ```js
sum(1, 2, 3) // -> 6 sum(1, 2, 3) // -> 6
sum(1, 2, 3, 4) // -> 10 sum(1, 2, 3, 4) // -> 10
``` ```
30. Writ a function which generates a _randomUserIp_. 1. Writ a function which generates a _randomUserIp_.
31. Write a function which generates a _randomMacAddress_ 1. Write a function which generates a _randomMacAddress_
32. Declare a function name _randomHexaNumberGenerator_. When this function is called it generates a random hexadecimal number. The function return the hexadecimal number. 1. Declare a function name _randomHexaNumberGenerator_. When this function is called it generates a random hexadecimal number. The function return the hexadecimal number.
```sh ```sh
console.log(randomHexaNumberGenerator()); console.log(randomHexaNumberGenerator());
'#ee33df' '#ee33df'
``` ```
33. Declare a function name _userIdGenerator_. When this function is called it generates seven character id. The function return the id. 1. Declare a function name _userIdGenerator_. When this function is called it generates seven character id. The function return the id.
```sh ```sh
console.log(userIdGenerator()); console.log(userIdGenerator());
41XTDbE 41XTDbE
``` ```
34. Modify question number n . Declare a function name _userIdGeneratedByUser_. It doesnt take any parameter but it takes two inputs using prompt(). One of the input is the number of characters and the second input is the number of ids which are supposed to be generated. ### Exercises: Level 3
1. Modify question number n . Declare a function name _userIdGeneratedByUser_. It doesnt take any parameter but it takes two inputs using prompt(). One of the input is the number of characters and the second input is the number of ids which are supposed to be generated.
```sh ```sh
userIdGeneratedByUser() userIdGeneratedByUser()
@ -626,18 +635,18 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra
' '
``` ```
35. Write a function name _rgbColorGenerator_ and it generates rgb colors. 1. Write a function name _rgbColorGenerator_ and it generates rgb colors.
```sh ```sh
rgbColorGenerator() rgbColorGenerator()
rgb(125,244,255) rgb(125,244,255)
``` ```
36. Write a function **_arrayOfHexaColors_** which return any number of hexadecimal colors in an array. 1. Write a function **_arrayOfHexaColors_** which return any number of hexadecimal colors in an array.
37. Write a function **_arrayOfRgbColors_** which return any number of RGB colors in an array. 1. Write a function **_arrayOfRgbColors_** which return any number of RGB colors in an array.
38. Write a function **_convertHexaToRgb_** which converts hexa color to rgb and it returns an rgb color. 1. Write a function **_convertHexaToRgb_** which converts hexa color to rgb and it returns an rgb color.
39. Write a function **_convertRgbToHexa_** which converts rgb to hexa color and it returns an hexa color. 1. Write a function **_convertRgbToHexa_** which converts rgb to hexa color and it returns an hexa color.
40. Write a function **_generateColors_** which can generate any number of hexa or rgb colors. 1. Write a function **_generateColors_** which can generate any number of hexa or rgb colors.
```js ```js
console.log(generateColors('hexa', 3)) // ['#a3e12f', '#03ed55', '#eb3d2b'] console.log(generateColors('hexa', 3)) // ['#a3e12f', '#03ed55', '#eb3d2b']
@ -646,34 +655,50 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra
console.log(generateColors('rgb', 1)) // 'rgb(33,79, 176)' console.log(generateColors('rgb', 1)) // 'rgb(33,79, 176)'
``` ```
41. Call your function _shuffleArray_, it takes an array as a parameter and it returns a shuffled array 1. Call your function _shuffleArray_, it takes an array as a parameter and it returns a shuffled array
42. Call your function _factorial_, it takes a whole number as a parameter and it return a factorial of the number 1. Call your function _factorial_, it takes a whole number as a parameter and it return a factorial of the number
43. Call your function _isEmpty_, it takes a parameter and it checks if it is empty or not 1. Call your function _isEmpty_, it takes a parameter and it checks if it is empty or not
44. Call your function _sum_, it takes any number of arguments and it returns the sum. 1. Call your function _sum_, it takes any number of arguments and it returns the sum.
45. Write a function called _sumOfArrayItems_, it takes an array parameter and return the sum of all the items. Check if all the array items are number types. If not give return reasonable feedback. 1. Write a function called _sumOfArrayItems_, it takes an array parameter and return the sum of all the items. Check if all the array items are number types. If not give return reasonable feedback.
46. Write a function called _average_, it takes an array parameter and returns the average of the items. Check if all the array items are number types. If not give return reasonable feedback. 1. Write a function called _average_, it takes an array parameter and returns the average of the items. Check if all the array items are number types. If not give return reasonable feedback.
47. Write a function called _modifyArray_ takes array as parameter and modifies the fifth item of the array and return the array. If the array length is less than five it return 'item not found'. 1. Write a function called _modifyArray_ takes array as parameter and modifies the fifth item of the array and return the array. If the array length is less than five it return 'item not found'.
```js ```js
console.log(modifyArray(['Avocado', 'Tomato', 'Potato','Mango', 'Lemon','Carrot']); console.log(modifyArray(['Avocado', 'Tomato', 'Potato','Mango', 'Lemon','Carrot']);
// →['Avocado', 'Tomato', 'Potato','Mango', 'LEMON', 'Carrot'] ```
```sh
['Avocado', 'Tomato', 'Potato','Mango', 'LEMON', 'Carrot']
```
```js
console.log(modifyArray(['Google', 'Facebook','Apple', 'Amazon','Microsoft', 'IBM']); console.log(modifyArray(['Google', 'Facebook','Apple', 'Amazon','Microsoft', 'IBM']);
// →['Google', 'Facebook','Apple', 'Amazon','MICROSOFT', 'IBM'] ```
```sh
['Google', 'Facebook','Apple', 'Amazon','MICROSOFT', 'IBM']
```
```js
console.log(modifyArray(['Google', 'Facebook','Apple', 'Amazon']); console.log(modifyArray(['Google', 'Facebook','Apple', 'Amazon']);
// →'Not Found'
``` ```
48. Write a function called _isPrime_, which checks if a number is prime number. ```sh
49. Write a functions which checks if all items are unique in the array. 'Not Found'
50. Write a function which checks if all the items of the array are the same data type. ```
51. JavaScript variable name does not support special characters or symbols except \$ or \_. Write a function **\*isValidVariable** which check if a variable is valid or invalid variable.
52. Write a function which returns array of seven random numbers in a range of 0-9. All the numbers must be unique. 1. Write a function called _isPrime_, which checks if a number is prime number.
1. Write a functions which checks if all items are unique in the array.
1. Write a function which checks if all the items of the array are the same data type.
1. JavaScript variable name does not support special characters or symbols except \$ or \_. Write a function **\*isValidVariable** which check if a variable is valid or invalid variable.
1. Write a function which returns array of seven random numbers in a range of 0-9. All the numbers must be unique.
```js ```js
sevenRandomNumbers()[(1, 4, 5, 7, 9, 8, 0)] sevenRandomNumbers()
[(1, 4, 5, 7, 9, 8, 0)]
``` ```
53. Write a function called reverseCountries, it takes countries array and first it copy the array and returns the reverse of the original array 1. Write a function called reverseCountries, it takes countries array and first it copy the array and returns the reverse of the original array
🎉 CONGRATULATIONS ! 🎉 🎉 CONGRATULATIONS ! 🎉

@ -34,6 +34,8 @@
- [Getting object keys and values using Object.entries()](#getting-object-keys-and-values-using-objectentries) - [Getting object keys and values using Object.entries()](#getting-object-keys-and-values-using-objectentries)
- [Checking properties using hasOwnProperty()](#checking-properties-using-hasownproperty) - [Checking properties using hasOwnProperty()](#checking-properties-using-hasownproperty)
- [💻 Exercises](#%f0%9f%92%bb-exercises) - [💻 Exercises](#%f0%9f%92%bb-exercises)
- [Exercises: Level 1](#exercises-level-1)
- [Exercises: Level 2](#exercises-level-2)
# 📔 Day 8 # 📔 Day 8
@ -418,12 +420,17 @@ console.log(copyPerson.hasOwnProperty('score'))
## 💻 Exercises ## 💻 Exercises
### Exercises: Level 1
1. Create an empty object called dog 1. Create an empty object called dog
1. Print the the dog object on the console 1. Print the the dog object on the console
1. Add name, legs, color, age and bark properties for the dog object. The bark property is a method which return _woof woof_ 1. Add name, legs, color, age and bark properties for the dog object. The bark property is a method which return _woof woof_
1. Get name, legs, color, age and bark value from the dog object 1. Get name, legs, color, age and bark value from the dog object
1. Set new properties the dog object: breed, getDogInfo 1. Set new properties the dog object: breed, getDogInfo
1. Create an object literal called _personAccount_. It has _firstName, lastName, incomes, expenses_ properties and it has _totalIncome, totalExpense, accountInfo,addIncome, addExpense_ and _accountBalance_ methods. Incomes is a set of incomes and its description and expenses is a set of incomes and its description.
### Exercises: Level 2
1. Find the person who has many skills in the users object.
1. Count logged in users,count users having greater than equal to 50 points from the following object. 1. Count logged in users,count users having greater than equal to 50 points from the following object.
````js ````js
@ -479,14 +486,104 @@ console.log(copyPerson.hasOwnProperty('score'))
} }
}``` }```
````
1. Find people who are MERN stack developer from the users object 1. Find people who are MERN stack developer from the users object
1. Set your name in the users object without modifying the original users object 1. Set your name in the users object without modifying the original users object
1. Get all keys or properties of users object 1. Get all keys or properties of users object
1. Get all the values of users object 1. Get all the values of users object
1. Use the countries object to print a country name, capital, populations and languages. 1. Use the countries object to print a country name, capital, populations and languages.
### Exercises: Level 3
1. Create an object literal called _personAccount_. It has _firstName, lastName, incomes, expenses_ properties and it has _totalIncome, totalExpense, accountInfo,addIncome, addExpense_ and _accountBalance_ methods. Incomes is a set of incomes and its description and expenses is a set of incomes and its description.
2. **** Questions:2, 3 and 4 are based on the following two arrays:users and products ()
```js
const users = [
{
_id: 'ab12ex',
username: 'Alex',
email: 'alex@alex.com',
password: '123123',
createdAt:'08/01/2020 9:00 AM',
isLoggedIn: false
},
{
_id: 'fg12cy',
username: 'Asab',
email: 'asab@asab.com',
password: '123456',
createdAt:'08/01/2020 9:30 AM',
isLoggedIn: true
},
{
_id: 'zwf8md',
username: 'Brook',
email: 'brook@brook.com',
password: '123111',
createdAt:'08/01/2020 9:45 AM',
isLoggedIn: true
},
{
_id: 'eefamr',
username: 'Martha',
email: 'martha@martha.com',
password: '123222',
createdAt:'08/01/2020 9:50 AM',
isLoggedIn: false
},
{
_id: 'ghderc',
username: 'Thomas',
email: 'thomas@thomas.com',
password: '123333',
createdAt:'08/01/2020 10:00 AM',
isLoggedIn: false
}
];
const products = [
{
_id: 'eedfcf',
name: 'mobile phone',
description: 'Huawei Honor',
price: 200,
ratings: [
{ userId: 'fg12cy', rate: 5 },
{ userId: 'zwf8md', rate: 4.5 }
],
likes: []
},
{
_id: 'aegfal',
name: 'Laptop',
description: 'MacPro: System Darwin',
price: 2500,
ratings: [],
likes: ['fg12cy']
},
{
_id: 'hedfcg',
name: 'TV',
description: 'Smart TV:Procaster',
price: 400,
ratings: [{ userId: 'fg12cy', rate: 5 }],
likes: ['fg12cy']
}
]
```
Imagine you are getting the above users collection from a MongoDB database.
a. Create a function called signUp which allows user to add to the collection. If user exists, inform the user that he has already an account.
b. Create a function called signIn which allows user to sign in to the application
3. The products array has three elements and each of them has six properties.
a. Create a function called rateProduct which rates the product
b. Create a function called averageRating which calculate the average rating of a product
4. Create a function called likeProduct. This function will helps to like to the product if it is not liked and remove like if it was liked.
🎉 CONGRATULATIONS ! 🎉 🎉 CONGRATULATIONS ! 🎉

@ -38,6 +38,9 @@
- [Sorting Numeric values](#sorting-numeric-values) - [Sorting Numeric values](#sorting-numeric-values)
- [Sorting Object Arrays](#sorting-object-arrays) - [Sorting Object Arrays](#sorting-object-arrays)
- [💻 Exercises](#%f0%9f%92%bb-exercises) - [💻 Exercises](#%f0%9f%92%bb-exercises)
- [Exercises: Level 1](#exercises-level-1)
- [Exercises: Level 2](#exercises-level-2)
- [Exercises: Level 3](#exercises-level-3)
# Day 9 # Day 9
@ -553,6 +556,8 @@ console.log(users) // sorted ascending
## 💻 Exercises ## 💻 Exercises
### Exercises: Level 1
```js ```js
const countries = ['Finland', 'Sweden', 'Denmark', 'Norway', 'IceLand'] const countries = ['Finland', 'Sweden', 'Denmark', 'Norway', 'IceLand']
const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook'] const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook']
@ -582,8 +587,6 @@ const products = [
13. Use **_filter_** to filter out countries containing six letters and more in the country array. 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'; 14. Use **_filter_** to filter out country start with 'E';
15. Use **_filter_** to filter out only prices with values. 15. Use **_filter_** to filter out only prices with values.
16. Find the total price of products by chaining two or more array iterators(eg. arr.map(callback).filter(callback).reduce(callback))
17. Find the sum of price of products using only reduce reduce(callback))
18. Declare a function called getStringLists which takes an array as a parameter and then returns an array only with string items. 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. 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_** 20. Use **_reduce_** to concatenate all the countries and to produce this sentence: **_Estonia, Finland, Sweden, Denmark, Norway, and IceLand are north European countries_**
@ -595,13 +598,21 @@ const products = [
26. Use **_findIndex_** to find the position of 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. 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. 28. Use **_findIndex_** to find the position of **_Russia_** if it doesn't exist in the array you will get -1.
29. Declare a function called **_categorizeCountries_** which returns an array of countries which have some common pattern(you find the countries array in this repository as countries.js(eg 'land', 'ia', 'island','stan')).
30. Create a function which return an array of objects, which is the letter and the number of times the letter use to start with a name of a country. ### Exercises: Level 2
31. Declare a **_getFirstTenCountries_** function and return an array of ten countries. Use different functional programming to work on the countries.js array
32. Declare a **_getLastTenCountries_** function which which returns the last ten countries in the countries array. 1. Find the total price of products by chaining two or more array iterators(eg. arr.map(callback).filter(callback).reduce(callback))
33. Find out which _letter_ is used many _times_ as initial for a country name from the countries array (eg. Finland, Fiji, France etc) 1. Find the sum of price of products using only reduce reduce(callback))
34. Use the countries information, in the data folder. Sort countries by name, by capital, by population 1. Declare a function called **_categorizeCountries_** which returns an array of countries which have some common pattern(you find the countries array in this repository as countries.js(eg 'land', 'ia', 'island','stan')).
35. \*\*\* Find the 10 most spoken languages: 1. Create a function which return an array of objects, which is the letter and the number of times the letter use to start with a name of a country.
1. Declare a **_getFirstTenCountries_** function and return an array of ten countries. Use different functional programming to work on the countries.js array
1. Declare a **_getLastTenCountries_** function which which returns the last ten countries in the countries array.
1. Find out which _letter_ is used many _times_ as initial for a country name from the countries array (eg. Finland, Fiji, France etc)
### Exercises: Level 3
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 ````js
// Your output should look like this // Your output should look like this
@ -628,66 +639,65 @@ const products = [
```` ````
36. \*\*\* Use countries_data.js file create a function which create the ten most populated countries 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}
]```
````
37. \*\*\* 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 ````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(mostPopulatedCountries(countries, 10))
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()) {country: 'China', population: 1377422166},
Count: 25 {country: 'India', population: 1295210000},
Sum: 744 {country: 'United States of America', population: 323947000},
Min: 24 {country: 'Indonesia', population: 258705000},
Max: 38 {country: 'Brazil', population: 206135893},
Range: 14 {country: 'Pakistan', population: 194125062},
Mean: 30 {country: 'Nigeria', population: 186988000},
Median: 29 {country: 'Bangladesh', population: 161006790},
Mode: (26, 5) {country: 'Russian Federation', population: 146599183},
Variance: 17.5 {country: 'Japan', population: 126960000}
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)]
``` 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)]
```
🎉 CONGRATULATIONS ! 🎉 🎉 CONGRATULATIONS ! 🎉

@ -35,6 +35,9 @@
- [Getting a value from Map](#getting-a-value-from-map) - [Getting a value from Map](#getting-a-value-from-map)
- [Checking key in Map](#checking-key-in-map) - [Checking key in Map](#checking-key-in-map)
- [Exercises](#exercises) - [Exercises](#exercises)
- [Exercises:Level 1](#exerciseslevel-1)
- [Exercises:Level 2](#exerciseslevel-2)
- [Exercises:Level 3](#exerciseslevel-3)
# Day 10 # Day 10
@ -384,13 +387,29 @@ Norway Oslo
## Exercises ## Exercises
### Exercises:Level 1
```js
const a = {4, 5, 8, 9}
const b = {3, 4, 5, 7}
const countries = ['Finland', 'Sweden', 'Norway']
```
1. create an empty set 1. create an empty set
2. Create a set containing 0 to 10 using loop 2. Create a set containing 0 to 10 using loop
3. Remove an element from a set 3. Remove an element from a set
4. Clear a set 4. Clear a set
5. Create a set of 5 string elements from array 5. Create a set of 5 string elements from array
6. Create a map of countries and number of characters of a country 6. Create a map of countries and number of characters of a country
7. \*\*\* Find the 10 most spoken languages:
### Exercises:Level 2
1. Find a union b
2. Find a intersection b
3. Find a with b
### Exercises:Level 3
1. \*\*\* Use the countries data to find the 10 most spoken languages:
````js ````js
// Your output should look like this // Your output should look like this

@ -31,7 +31,10 @@
- [Spread operator to copy array](#spread-operator-to-copy-array) - [Spread operator to copy array](#spread-operator-to-copy-array)
- [Spread operator to copy object](#spread-operator-to-copy-object) - [Spread operator to copy object](#spread-operator-to-copy-object)
- [Spread operator with arrow function](#spread-operator-with-arrow-function) - [Spread operator with arrow function](#spread-operator-with-arrow-function)
- [Exercise](#exercise) - [Exercises](#exercises)
- [Exercises: Level 1](#exercises-level-1)
- [Exercises: Level 2](#exercises-level-2)
- [Exercises: Level 3](#exercises-level-3)
# Day 11 # Day 11
@ -526,7 +529,9 @@ console.log(sumAllNums(1, 2, 3,4,5))
🌕 You achieved quite a lot so far. Now, your level of JavaScript is upper intermediate. Keep going! You have just completed day 11 challenges and you are 11 steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle. 🌕 You achieved quite a lot so far. Now, your level of JavaScript is upper intermediate. Keep going! You have just completed day 11 challenges and you are 11 steps a head in to your way to greatness. Now do some exercises for your brain and for your muscle.
## Exercise ## Exercises
### Exercises: Level 1
```js ```js
const constants = [2.72, 3.14, 9.81, 37, 100] const constants = [2.72, 3.14, 9.81, 37, 100]
@ -586,9 +591,102 @@ const users = [
1. Destructure and assign the elements of constants array to e, pi, gravity, humanBodyTemp, waterBoilingTemp. 1. Destructure and assign the elements of constants array to e, pi, gravity, humanBodyTemp, waterBoilingTemp.
2. Destructure and assign the elements of countries array to fin, est, sw, den, nor 2. Destructure and assign the elements of countries array to fin, est, sw, den, nor
3. Destructure the rectangle object by its properties or keys. 3. Destructure the rectangle object by its properties or keys.
4. Iterate through the users array and get all the keys of the object using destructuring
5. Find the persons who have less than two skills ### Exercises: Level 2
6. Destructure the countries object print name, capital, population of all countries
1. Iterate through the users array and get all the keys of the object using destructuring
2. Find the persons who have less than two skills
### Exercises: Level 3
1. Destructure the countries object print name, capital, population and languages of all countries
2. A junior developer structure student name, skills and score in array of arrays which may not easy to read. Destruction the following array name to name, skills array to skills, scores array to scores, JavaScript score to jsScore and React score to reactScore variable.
```js
const student = ['David', ['HTM', 'CSS', 'JS', 'React'], [98, 85, 90, 95]]
console.log(name, skills, scores, jsScore, reactScore)
```
3. Write a function called *convertArrayToObject* which can convert the array to a structure object.
```js
const students = [
['David', ['HTM', 'CSS', 'JS', 'React'], [98, 85, 90, 95]],
['John', ['HTM', 'CSS', 'JS', 'React'], [85, 80, 85, 80]]
]
console.log(convertArrayToObject(students))
[
{
name: 'David',
skills: ['HTM','CSS','JS','React'],
scores: [98,85,90,95]
},
{
name: 'John',
skills: ['HTM','CSS','JS','React'],
scores: [85, 80,85,80]
}
]
```
4. Copy the student object to newStudent without mutating the original object. In the new object add the following ?
- Add Bootstrap with level 8 to the front end skill sets
- Add Express with level 9 to the back end skill sets
- Add SQL with level 8 to the data base skill sets
- Add SQL without level to the data science skill sets
```js
const student = {
name: 'David',
age: 25,
skills: {
frontEnd: [
{ skill: 'HTML', level: 10 },
{ skill: 'CSS', level: 8 },
{ skill: 'JS', level: 8 },
{ skill: 'React', level: 9 }
],
backEnd: [
{ skill: 'Node',level: 7 },
{ skill: 'GraphQL', level: 8 },
],
dataBase:[
{ skill: 'MongoDB', level: 7.5 },
],
dataScience:['Python', 'R', 'D3.js']
}
}
```
The copied object output should look like this:
```js
{
name: 'David',
age: 25,
skills: {
frontEnd: [
{skill: 'HTML',level: 10},
{skill: 'CSS',level: 8},
{skill: 'JS',level: 8},
{skill: 'React',level: 9},
{skill: 'BootStrap',level: 8}
],
backEnd: [
{skill: 'Node',level: 7},
{skill: 'GraphQL',level: 8},
{skill: 'Express',level: 9}
],
dataBase: [
{ skill: 'MongoDB',level: 7.5},
{ skill: 'SQL',level: 8}
],
dataScience: ['Python','R','D3.js','SQL']
}
}
🎉 CONGRATULATIONS ! 🎉 🎉 CONGRATULATIONS ! 🎉

Loading…
Cancel
Save