pull/214/merge
Asabeneh 3 years ago
parent 07143be3b7
commit b094b3f64f

@ -382,7 +382,7 @@ These are not all the window methods we will have a separate section to go deep
## Date Object
Time is an important thing. We like to know the time a certain activity or event. In JavaScript current time and date is created using JavaScript Date Object. The object we create using Date object provides many methods to work with date and time.The methods we use to get date and time information from a date object values are started with a word _get_ because it provide the information.
_getFullYear(), getMonths(), getDate(), getDay(), getHours(), getMinutes, getSeconds(), getMilliseconds(), getTime(), getDay()_
_getFullYear(), getMonth(), getDate(), getDay(), getHours(), getMinutes, getSeconds(), getMilliseconds(), getTime(), getDay()_
![Date time Object](../images/date_time_object.png)
@ -553,7 +553,7 @@ console.log(`${date}/${month}/${year} ${hours}:${minutes}`) // 4/1/2020 0:56
```sh
Enter base: 20
Enter height: 10
The area of the triangle is 50
The area of the triangle is 100
```
1. Write a script that prompt the user to enter side a, side b, and side c of the triangle and and calculate the perimeter of triangle (perimeter = a + b + c)

@ -13,7 +13,7 @@
</sub>
</div>
[<< Day 4](../04_Day_Conditionals/04_day_Conditionals.md) | [Day 6 >>](../06_Day_Loops/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)

@ -178,7 +178,7 @@ for (const num of numbers) {
// adding all the numbers in the array
let sum = 0
for (const num of numbers) {
sum += sum + num // can be also shorten like this, sum += num
sum = sum + num // can be also shorten like this, sum += num
}
console.log(sum) // 15

@ -241,7 +241,6 @@ console.log(C)
```sh
Set(6) {1, 2, 3, 4, 5,6}
```
### Intersection of sets
@ -263,7 +262,6 @@ console.log(C)
```sh
Set(3) {3, 4, 5}
```
### Difference of sets
@ -285,7 +283,6 @@ console.log(C)
```sh
Set(2) {1, 2}
```
## Map
@ -372,7 +369,7 @@ for (const country of countriesMap) {
(2) ["Norway", "Oslo"]
```
```sh
```js
for (const [country, city] of countriesMap){
console.log(country, city)
}
@ -415,10 +412,11 @@ 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 },
console.log(mostSpokenLanguages(countries, 10))
[
{ English: 91 },
{ French: 45 },
{ Arabic: 25 },
{ Spanish: 24 },
@ -428,24 +426,20 @@ const countries = ['Finland', 'Sweden', 'Norway']
{ German: 7 },
{ Chinese: 5 },
{ Swahili: 4 },
{ Serbian: 4 })
{ Serbian: 4 }
]
// Your output should look like this
console.log(mostSpokenLanguages(countries, 3))
```
[
{'English':91},
{'French':45},
{'Arabic':25}
]
// Your output should look like this
console.log(mostSpokenLanguages(countries, 3))
[
{'English':91},
{'French':45},
{'Arabic':25}
]
```
🎉 CONGRATULATIONS ! 🎉
[<< Day 9](../09_Day_Higher_order_functions/09_day_higher_order_functions.md) | [Day 11>>](../11_Day_Destructuring_and_spreading/11_day_destructuring_and_spreading.md)
```
[<< 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,9 +57,9 @@ 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, fourthPerson] = names
console.log(firstName, secondPerson,thirdPerson, fourthPerson)
console.log(firstPerson, secondPerson,thirdPerson, fourthPerson)
```
```sh

@ -172,7 +172,8 @@ doPromise
The Fetch API provides an interface for fetching resources (including across the network). It will seem familiar to anyone who has used XMLHttpRequest, but the new API provides a more powerful and flexible feature set. In this challenge we will use fetch to request url and APIS. In addition to that let us see demonstrate use case of promises in accessing network resources using the fetch API.
```js
const url = 'https://restcountries.eu/rest/v2/all' // countries api
const url = 'https://restcountries.com/v2/all' // countries api
fetch(url)
.then(response => response.json()) // accessing the API data as JSON
.then(data => { // getting the data
@ -219,7 +220,7 @@ Let us fetch API data using both promise method and async and await method.
- promise
```js
const url = 'https://restcountries.eu/rest/v2/all'
const url = 'https://restcountries.com/v2/all'
fetch(url)
.then(response => response.json())
.then(data => {
@ -249,7 +250,7 @@ fetchData()
## Exercises
```js
const countriesAPI = 'https://restcountries.eu/rest/v2/all'
const countriesAPI = 'https://restcountries.com/v2/all'
const catsAPI = 'https://api.thecatapi.com/v1/breeds'
```

@ -214,7 +214,7 @@ const titles = document.querySelectorAll('h1')
titles[3].textContent = 'Fourth Title'
```
#### Adding Text Content using innHTML
#### Adding Text Content using innerHTML
Most people get confused between _textContent_ and _innerHTML_. _textContent_ is meant to add text to an HTML element, however innerHTML can add a text or HTML element or elements as a child.

@ -205,7 +205,7 @@ console.log('Hello, World!')
##### Console.log with Multiple Arguments
The **conole.log()** function can take multiple parameters separated by comma. The syntax looks like as follows:**console.log(param1, param2, param3)**
The **console.log()** function can take multiple parameters separated by comma. The syntax looks like as follows:**console.log(param1, param2, param3)**
![console log multiple arguments](./images/console_log_multipl_arguments.png)
@ -231,11 +231,11 @@ We add comments to our code. Comments are very important to make code more reada
**Example: Multiline Comment**
/_
/*
This is a multiline comment
Multiline comments can take multiple lines
JavaScript is the language of the web
_/
*/
##### Syntax
@ -527,18 +527,18 @@ Multiline commenting:
```js
/*
let location = 'Helsinki';
let age = 100;
let isMarried = true;
This is a Multiple line comment
*/
let location = 'Helsinki';
let age = 100;
let isMarried = true;
This is a Multiple line comment
*/
```
## Variables
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. We will talk more about var, let, and const in detail in other sections (scope). For now, the above explanation is enough.
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 not 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 variable name must follow the following rules:
@ -571,7 +571,7 @@ 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.
The first and second variables on the list follows the camelCase convention of declaring in JavaScript. In this material, we will use camelCase variables.
Example of invalid variables:
@ -603,16 +603,15 @@ console.log(firstName, lastName, country, city, age, isMarried)
```
```sh
Asabeneh Yetayeh Finland Helsinki 100 True
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 boilingPoint = 100 // water boiling point, temperature in °C
const PI = 3.14 // geometrical constant
console.log(gravity, boilingPoint, PI)
```
@ -623,8 +622,8 @@ console.log(gravity, boilingPoint, PI)
```js
// Variables can also be declaring in one line separated by comma
let name = 'Asabeneh', // name of a person
job = 'teacher',
live = 'Finland'
job = 'teacher',
live = 'Finland'
console.log(name, job, live)
```

Loading…
Cancel
Save