pull/1023/merge
inoovador 3 weeks ago committed by GitHub
commit fdcc8aaf97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -450,7 +450,7 @@ console.log(firstName.length) // 8
2. *Accessing characters in a string*: We can access each character in a string using its index. In programming, counting starts from 0. The first index of the string is zero, and the last index is the length of the string minus one.
![Accessing sting by index](../images/string_indexes.png)
![Accessing string by index](../images/string_indexes.png)
Let us access different characters in 'JavaScript' string.

@ -556,7 +556,7 @@ console.log(`${date}/${month}/${year} ${hours}:${minutes}`) // 4/1/2020 0:56
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)
1. Write a script that prompt the user to enter side a, side b, and side c of the triangle and calculate the perimeter of triangle (perimeter = a + b + c)
```sh
Enter side a: 5
@ -613,7 +613,7 @@ console.log(`${date}/${month}/${year} ${hours}:${minutes}`) // 4/1/2020 0:56
You are 15. You will be allowed to drive after 3 years.
```
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. Write a script that prompt the user to enter number of years. Calculate the number of seconds a person can live. Assume someone lives just hundred years
```sh
Enter number of years you live: 100

@ -318,12 +318,12 @@ isRaining
2 is an even number
Enter a number: 9
9 is is an odd number.
9 is an odd number.
```
### Exercises: Level 2
1. Write a code which can give grades to students according to theirs scores:
1. Write a code which can give grades to students according to their scores:
- 80-100, A
- 70-89, B
- 60-69, C

@ -430,7 +430,7 @@ console.log(copyPerson.hasOwnProperty('score'))
### Exercises: Level 1
1. Create an empty object called dog
1. Print the the dog object on the console
1. Print 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. Get name, legs, color, age and bark value from the dog object
1. Set new properties the dog object: breed, getDogInfo

@ -222,7 +222,7 @@ Set(5) {5, 3, 2, 9, 4}
### Union of sets
To find a union to two sets can be achieved using spread operator. Lets find the union of set A and set B (A U B)
To find a union of two sets can be achieved using spread operator. Let's find the union of set A and set B (A U B)
```js
let a = [1, 2, 3, 4, 5]
@ -242,7 +242,7 @@ Set(6) {1, 2, 3, 4, 5,6}
### Intersection of sets
To find an intersection of two sets can be achieved using filter. Lets find the intersection of set A and set B (A ∩ B)
To find an intersection of two sets can be achieved using filter. Let's find the intersection of set A and set B (A ∩ B)
```js
let a = [1, 2, 3, 4, 5]
@ -263,7 +263,7 @@ Set(3) {3, 4, 5}
### Difference of sets
To find an the difference between two sets can be achieved using filter. Lets find the different of set A and set B (A \ B)
To find the difference between two sets can be achieved using filter. Let's find the difference of set A and set B (A \ B)
```js
let a = [1, 2, 3, 4, 5]

@ -82,7 +82,7 @@ ReferenceError: fistName is not defined
at <anonymous>:4:20
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.
The catch block takes 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. Let's use the name and message.
```js
try {
let lastName = 'Yetayeh'

@ -75,7 +75,7 @@ Some use case of Web Storages are
For the examples mentioned above, it makes sense to use localStorage. You may be wondering, then, when we should use sessionStorage.
In cases, we want to to get rid of the data as soon as the window is closed. Or, perhaps, if we do not want the application to interfere with the same application thats open in another window. These scenarios are served best with sessionStorage.
In cases, we want to get rid of the data as soon as the window is closed. Or, perhaps, if we do not want the application to interfere with the same application thats open in another window. These scenarios are served best with sessionStorage.
Now, let us see how make use of these Web Storage APIs.

@ -180,12 +180,12 @@ const showDateTime = () => {
}
```
The `new Dat().toLocaleString()` can also be used to display current date time. The `toLocaleString()` methods takes different arguments. You may learn more about date and time from this [link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString).
The `new Date().toLocaleString()` can also be used to display current date time. The `toLocaleString()` methods takes different arguments. You may learn more about date and time from this [link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString).
#### Loops
We coverer many types of loops in this challenges. The regular for loop, while loop, do while loop, for of loop, forEach loop and for in loop.
Lets see how we use them:
We covered many types of loops in this challenge. The regular for loop, while loop, do while loop, for of loop, forEach loop and for in loop.
Let's see how we use them:
```js
for (let i = 0; i < n; i++){

@ -154,7 +154,7 @@ const allTitles = document.querySelectorAll('.title') // the same goes for selec
### Adding attribute
An attribute is added in the opening tag of HTML which gives additional information about the element. Common HTML attributes: id, class, src, style, href,disabled, title, alt. Lets add id and class for the fourth title.
An attribute is added in the opening tag of HTML which gives additional information about the element. Common HTML attributes: id, class, src, style, href, disabled, title, alt. Let's add id and class for the fourth title.
```js
const titles = document.querySelectorAll('h1')
@ -351,7 +351,7 @@ As you have notice, the properties of css when we use it in JavaScript is going
### Exercise: Level 1
1. Create an index.html file and put four p elements as above: Get the first paragraph by using **_document.querySelector(tagname)_** and tag name
2. Get each of the the paragraph using **_document.querySelector('#id')_** and by their id
2. Get each of the paragraphs using **_document.querySelector('#id')_** and by their id
3. Get all the p as nodeList using **_document.querySelectorAll(tagname)_** and by their tag name
4. Loop through the nodeList and get the text content of each paragraph
5. Set a text content to paragraph the fourth paragraph,**_Fourth Paragraph_**

Loading…
Cancel
Save