pull/103/head
Asabeneh 5 years ago
parent 8d0e1b0ecd
commit 585c33e790

@ -272,7 +272,7 @@ console.log(count++) // 0
console.log(count) // 1 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 ### 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. 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. 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. 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 ```sh
Enter hours: 40 Enter hours: 40

@ -7,10 +7,11 @@
<img alt="Twitter Follow" src="https://img.shields.io/twitter/follow/asabeneh?style=social"> <img alt="Twitter Follow" src="https://img.shields.io/twitter/follow/asabeneh?style=social">
</a> </a>
<sub>Author: <sub>Author:
<a href="https://www.linkedin.com/in/asabeneh/" target="_blank">Asabeneh Yetayeh</a><br> <a href="https://www.linkedin.com/in/asabeneh/" target="_blank">Asabeneh Yetayeh</a><br>
<small> January, 2020</small> <small> January, 2020</small>
</sub> </sub>
</div> </div>
[<< 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 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)
@ -67,7 +68,7 @@ const languages = [
'French', 'French',
'Spanish', 'Spanish',
'English', 'English',
'French' 'French',
] ]
const setOfLangauges = new Set(languages) const setOfLangauges = new Set(languages)
@ -88,7 +89,7 @@ const languages = [
'French', 'French',
'Spanish', 'Spanish',
'English', 'English',
'French' 'French',
] ]
const setOfLangauges = new Set(languages) const setOfLangauges = new Set(languages)
@ -183,7 +184,7 @@ const languages = [
'French', 'French',
'Spanish', 'Spanish',
'English', 'English',
'French' 'French',
] ]
const langSet = new Set(languages) const langSet = new Set(languages)
console.log(langSet) // Set(4) {"English", "Finnish", "French", "Spanish"} console.log(langSet) // Set(4) {"English", "Finnish", "French", "Spanish"}
@ -193,7 +194,7 @@ const counts = []
const count = {} const count = {}
for (const l of langSet) { 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"] console.log(filteredLang) // ["English", "English", "English"]
counts.push({ lang: l, count: filteredLang.length }) counts.push({ lang: l, count: filteredLang.length })
} }
@ -201,11 +202,11 @@ console.log(counts)
``` ```
```js ```js
[ ;[
{ lang: 'English', count: 3 }, { lang: 'English', count: 3 },
{ lang: 'Finnish', count: 1 }, { lang: 'Finnish', count: 1 },
{ lang: 'French', count: 2 }, { 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 A = new Set(a)
let B = new Set(b) 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) let C = new Set(c)
console.log(C) console.log(C)
@ -276,7 +277,7 @@ let b = [3, 4, 5, 6]
let A = new Set(a) let A = new Set(a)
let B = new Set(b) 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) let C = new Set(c)
console.log(C) console.log(C)
@ -306,7 +307,7 @@ Map(0) {}
countries = [ countries = [
['Finland', 'Helsinki'], ['Finland', 'Helsinki'],
['Sweden', 'Stockholm'], ['Sweden', 'Stockholm'],
['Norway', 'Oslo'] ['Norway', 'Oslo'],
] ]
const map = new Map(countries) const map = new Map(countries)
console.log(map) console.log(map)
@ -347,7 +348,7 @@ Helsinki
### Checking key in Map ### 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 ```js
console.log(countriesMap.has('Finland')) console.log(countriesMap.has('Finland'))
@ -416,32 +417,35 @@ const countries = ['Finland', 'Sweden', 'Norway']
```js ```js
// Your output should look like this // Your output should look like this
console.log(mostSpokenLanguages(countries, 10)) console.log(mostSpokenLanguages(countries, 10))[
[ ({ English: 91 },
{'English':91}, { French: 45 },
{'French':45}, { Arabic: 25 },
{'Arabic':25}, { Spanish: 24 },
{'Spanish':24}, { Russian: 9 },
{'Russian':9}, { Portuguese: 9 },
{'Portuguese':9}, { Dutch: 8 },
{'Dutch':8}, { German: 7 },
{'German':7}, { Chinese: 5 },
{'Chinese':5}, { Swahili: 4 },
{'Swahili':4}, { Serbian: 4 })
{'Serbian':4}] ]
// Your output should look like this // Your output should look like this
console.log(mostSpokenLanguages(countries, 3)) console.log(mostSpokenLanguages(countries, 3))
[
{'English':91},
{'French':45},
{'Arabic':25}
]
``` ```
[
{'English':91},
{'French':45},
{'Arabic':25}
]
```
🎉 CONGRATULATIONS ! 🎉 🎉 CONGRATULATIONS ! 🎉
[<< Day 9](../09_Day_Higher_order_functions/09_day_higher_order_functions.md) | [Day 11>>](../11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md) [<< 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)
```

@ -57,7 +57,7 @@ Destructuring is a way to unpack arrays, and objects and assigning to a distinct
```js ```js
const names = ['Asabeneh', 'Brook', 'David', 'John'] 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) 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 ```js
const names = ['Asabeneh', 'Brook', 'David', 'John'] 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) console.log(secondPerson, fourthPerson)
``` ```

Loading…
Cancel
Save