Skip to content

Commit

Permalink
typo fixes and some minor corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Asabeneh committed Apr 16, 2022
1 parent 0f4a2b6 commit faace4f
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 101 deletions.
23 changes: 9 additions & 14 deletions 05_Day_Arrays/05_day_arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ An array is a collection of different data types which are ordered and changeabl
### How to create an empty array

In JavaScript, we can create an array in different ways. Let us see different ways to create an array.
It is very common to use *const* instead of *let* to declare an array variable. If you ar using const it means you do not use that variable name again.
It is very common to use _const_ instead of _let_ to declare an array variable. If you ar using const it means you do not use that variable name again.

- Using Array constructor

Expand Down Expand Up @@ -400,7 +400,7 @@ if(index === -1){
// we can use also ternary here
index === -1 ? console.log('This fruit does not exist in the array'): console.log('This fruit does exist in the array')

// let us check if a avocado exist in the array
// let us check if an avocado exist in the array
let indexOfAvocado = fruits.indexOf('avocado') // -1, if the element not found index is -1
if(indexOfAvocado === -1){
console.log('This fruit does not exist in the array')
Expand Down Expand Up @@ -521,18 +521,20 @@ Splice: It takes three parameters:Starting position, number of times to be remov

```js
const numbers = [1, 2, 3, 4, 5]

console.log(numbers.splice()) // -> remove all items
numbers.splice()
console.log(numbers) // -> remove all items

```

```js
const numbers = [1, 2, 3, 4, 5]
console.log(numbers.splice(0,1)) // remove the first item
numbers.splice(0,1)
console.log(numbers) // remove the first item
```

```js
const numbers = [1, 2, 3, 4, 5, 6];
const numbers = [1, 2, 3, 4, 5, 6]
numbers.splice(3, 3, 7, 8, 9)
console.log(numbers.splice(3, 3, 7, 8, 9)) // -> [1, 2, 3, 7, 8, 9] //it removes three item and replace three items
```

Expand All @@ -544,15 +546,13 @@ Push: adding item in the end. To add item to the end of an existing array we use
// syntax
const arr = ['item1', 'item2','item3']
arr.push('new item')

console.log(arr)
// ['item1', 'item2','item3','new item']
```

```js
const numbers = [1, 2, 3, 4, 5]
numbers.push(6)

console.log(numbers) // -> [1,2,3,4,5,6]

numbers.pop() // -> remove one item from the end
Expand All @@ -562,7 +562,6 @@ console.log(numbers) // -> [1,2,3,4,5]
```js
let fruits = ['banana', 'orange', 'mango', 'lemon']
fruits.push('apple')

console.log(fruits) // ['banana', 'orange', 'mango', 'lemon', 'apple']

fruits.push('lime')
Expand All @@ -576,7 +575,6 @@ pop: Removing item in the end.
```js
const numbers = [1, 2, 3, 4, 5]
numbers.pop() // -> remove one item from the end

console.log(numbers) // -> [1,2,3,4]
```

Expand All @@ -587,7 +585,6 @@ shift: Removing one array element in the beginning of the array.
```js
const numbers = [1, 2, 3, 4, 5]
numbers.shift() // -> remove one item from the beginning

console.log(numbers) // -> [2,3,4,5]
```

Expand All @@ -598,7 +595,6 @@ unshift: Adding array element in the beginning of the array.
```js
const numbers = [1, 2, 3, 4, 5]
numbers.unshift(0) // -> add one item from the beginning

console.log(numbers) // -> [0,1,2,3,4,5]
```

Expand All @@ -609,7 +605,6 @@ reverse: reverse the order of an array.
```js
const numbers = [1, 2, 3, 4, 5]
numbers.reverse() // -> reverse array order

console.log(numbers) // [5, 4, 3, 2, 1]

numbers.reverse()
Expand Down Expand Up @@ -769,7 +764,7 @@ const webTechs = [
- Find the median age(one middle item or two middle items divided by two)
- Find the average age(all items divided by number of items)
- Find the range of the ages(max minus min)
- Compare the value of (min - average) and (max - average), use *abs()* method
- Compare the value of (min - average) and (max - average), use _abs()_ method
1.Slice the first ten countries from the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js)
1. Find the middle country(ies) in the [countries array](https://github.com/Asabeneh/30DaysOfJavaScript/tree/master/data/countries.js)
2. Divide the countries array into two equal arrays if it is even. If countries array is not even , one more country for the first half.
Expand Down
2 changes: 1 addition & 1 deletion 07_Day_Functions/07_day_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ const sumAllNums = (...args) => {
console.log(args)
}

sumAllNums(1, 2, 3, 4))
sumAllNums(1, 2, 3, 4)
// [1, 2, 3, 4]

```
Expand Down
2 changes: 1 addition & 1 deletion 08_Day_Objects/08_day_objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ _Object.keys_: To get the keys or properties of an object as an array

```js
const keys = Object.keys(copyPerson)
console.log(keys) //['name', 'age', 'country', 'skills', 'address', 'getPersonInfo']
console.log(keys) //['firstName', 'age', 'country','city', 'skills','title', 'address', 'getPersonInfo']
const address = Object.keys(copyPerson.address)
console.log(address) //['street', 'pobox', 'city']
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ console.log(higherOrder(2)(3)(10))
Let us see were we use call back functions. For instance the _forEach_ method uses call back.

```js
const numbers = [1, 2, 3, 4]
const numbers = [1, 2, 3, 4, 5]
const sumArray = arr => {
let sum = 0
const callback = function(element) {
Expand Down Expand Up @@ -518,7 +518,7 @@ console.log(numbers) //[100, 37, 9.81, 3.14]
#### Sorting Object Arrays
When ever we sort objects in an array. We use the object key to compare. Lets see the example below.
Whenever we sort objects in an array, we use the object key to compare. Let us see the example below.
```js
objArr.sort(function (a, b) {
Expand All @@ -538,7 +538,7 @@ objArr.sort(function (a, b) {
const users = [
{ name: 'Asabeneh', age: 150 },
{ name: 'Brook', age: 50 },
{ name: 'Eyo', age: 100 },
{ name: 'Eyob', age: 100 },
{ name: 'Elias', age: 22 },
]
users.sort((a, b) => {
Expand Down
17 changes: 6 additions & 11 deletions 10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
## Set

Set is a collection of elements. Set can only contains unique elements.
Lets see how to create a set
Let us see how to create a set in the section below.

### Creating an empty set

Expand All @@ -55,7 +55,7 @@ console.log(companies)
```

```sh
{}
Set(0) {}
```

### Creating set from array
Expand Down Expand Up @@ -117,7 +117,6 @@ companies.add('Facebook')
companies.add('Amazon')
companies.add('Oracle')
companies.add('Microsoft')

console.log(companies.size) // 5 elements in the set
console.log(companies)
```
Expand Down Expand Up @@ -165,13 +164,11 @@ It removes all the elements from a set.

```js
companies.clear()

console.log(companies)
```

```sh
{}

Set(0) {}
```

See the example below to learn how to use set.
Expand Down Expand Up @@ -202,7 +199,7 @@ console.log(counts)
```

```js
;[
[
{ lang: 'English', count: 3 },
{ lang: 'Finnish', count: 1 },
{ lang: 'French', count: 2 },
Expand Down Expand Up @@ -345,7 +342,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 exists in a map using _has_ method. It returns _true_ or _false_.

```js
console.log(countriesMap.has('Finland'))
Expand All @@ -371,7 +368,7 @@ for (const country of countriesMap) {

```js
for (const [country, city] of countriesMap){
console.log(country, city)
console.log(country, city)
}
```

Expand Down Expand Up @@ -438,8 +435,6 @@ const countries = ['Finland', 'Sweden', 'Norway']
]
```


🎉 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)
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@
![Day 11](../images/banners/day_1_11.png)

- [Day 11](#day-11)
- [Destructuring and Spread](#destructuring-and-spread)
- [Destructing Arrays](#destructing-arrays)
- [Destructuring during iteration](#destructuring-during-iteration)
- [Destructuring Object](#destructuring-object)
- [Renaming during structuring](#renaming-during-structuring)
- [Object parameter without destructuring](#object-parameter-without-destructuring)
- [Object parameter with destructuring](#object-parameter-with-destructuring)
- [Destructuring object during iteration](#destructuring-object-during-iteration)
- [Spread or Rest Operator](#spread-or-rest-operator)
- [Spread operator to get the rest of array elements](#spread-operator-to-get-the-rest-of-array-elements)
- [Spread operator to copy array](#spread-operator-to-copy-array)
- [Spread operator to copy object](#spread-operator-to-copy-object)
- [Spread operator with arrow function](#spread-operator-with-arrow-function)
- [Exercises](#exercises)
- [Exercises: Level 1](#exercises-level-1)
- [Exercises: Level 2](#exercises-level-2)
- [Exercises: Level 3](#exercises-level-3)
- [Destructuring and Spread](#destructuring-and-spread)
- [Destructing Arrays](#destructing-arrays)
- [Destructuring during iteration](#destructuring-during-iteration)
- [Destructuring Object](#destructuring-object)
- [Renaming during structuring](#renaming-during-structuring)
- [Object parameter without destructuring](#object-parameter-without-destructuring)
- [Object parameter with destructuring](#object-parameter-with-destructuring)
- [Destructuring object during iteration](#destructuring-object-during-iteration)
- [Spread or Rest Operator](#spread-or-rest-operator)
- [Spread operator to get the rest of array elements](#spread-operator-to-get-the-rest-of-array-elements)
- [Spread operator to copy array](#spread-operator-to-copy-array)
- [Spread operator to copy object](#spread-operator-to-copy-object)
- [Spread operator with arrow function](#spread-operator-with-arrow-function)
- [Exercises](#exercises)
- [Exercises: Level 1](#exercises-level-1)
- [Exercises: Level 2](#exercises-level-2)
- [Exercises: Level 3](#exercises-level-3)

# Day 11

Expand Down Expand Up @@ -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, , fourthPerson] = name // first and third person is omitted
let [, secondPerson, , fourthPerson] = names // first and third person is omitted

console.log(secondPerson, fourthPerson)
```
Expand Down Expand Up @@ -218,7 +218,7 @@ console.log(w, h, a, p)
20 10 200 undefined
```

If the key is not found in the object the variable will be assigned to undefined. In case, the key is not in the object we can give a default value during declaration. See the example.
If the key is not found in the object the variable will be assigned to undefined. Sometimes the key might not be in the object, in that case we can give a default value during declaration. See the example.

```js
const rectangle = {
Expand All @@ -229,7 +229,7 @@ const rectangle = {
let { width, height, area, perimeter = 60 } = rectangle

console.log(width, height, area, perimeter) //20 10 200 60
//Lets modify the object:width to 30 and perimeter to 80
//Let us modify the object:width to 30 and perimeter to 80
```

```js
Expand All @@ -243,7 +243,7 @@ let { width, height, area, perimeter = 60 } = rectangle
console.log(width, height, area, perimeter) //30 10 200 80
```

Destructuring keys as a function parameters. Lets create a function which take a rectangle object and it return a perimeter of a rectangle.
Destructuring keys as a function parameters. Let us create a function which takes a rectangle object and it returns a perimeter of a rectangle.

### Object parameter without destructuring

Expand Down Expand Up @@ -282,7 +282,7 @@ const person = {
],
languages: ['Amharic', 'English', 'Suomi(Finnish)']
}
// Lets create a function which give information about the person object without destructuring
// Let us create a function which give information about the person object without destructuring

const getPersonInfo = obj => {
const skills = obj.skills
Expand Down Expand Up @@ -314,7 +314,7 @@ console.log(calculatePerimeter(rect)) // 60
```

```js
// Lets create a function which give information about the person object with destructuring
// Let us create a function which give information about the person object with destructuring
const getPersonInfo = ({
firstName,
lastName,
Expand All @@ -335,7 +335,7 @@ const getPersonInfo = ({
}
console.log(getPersonInfo(person))
/*
Asabeneh Yetayeh lives in Finland. He is 200 years old. He is an Instructor and Developer. He teaches HTML, CSS, JavaScript, React, Redux, Node, MongoDB, Python and D3.js. He speaks Amharic, English and a little bit of Suomi(Finnish)
Asabeneh Yetayeh lives in Finland. He is 250 years old. He is an Instructor and Developer. He teaches HTML, CSS, JavaScript, React, Redux, Node, MongoDB, Python and D3.js. He speaks Amharic, English and a little bit of Suomi(Finnish)
*/
```

Expand Down Expand Up @@ -373,7 +373,7 @@ Assess Test Result 4/1/2020 1:00 false

### Spread or Rest Operator

When we destructure an array we use the spread operator(...) to get the rest elements as array. In addition to that we use spread operator to spread arr elements to another array.
When we destructure an array we use the spread operator(...) to get the rest elements as array. In addition to that we use spread operator to spread array elements to another array.

### Spread operator to get the rest of array elements

Expand Down Expand Up @@ -499,7 +499,7 @@ const sumAllNums = (...args) => {
console.log(args)
}

sumAllNums(1, 2, 3,4,5)
sumAllNums(1, 2, 3, 4, 5)

```

Expand All @@ -519,7 +519,7 @@ const sumAllNums = (...args) => {

}

console.log(sumAllNums(1, 2, 3,4,5))
console.log(sumAllNums(1, 2, 3, 4, 5))
```

```sh
Expand Down Expand Up @@ -597,7 +597,6 @@ const users = [
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
Expand All @@ -613,7 +612,7 @@ const users = [
```

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]],
Expand Down Expand Up @@ -693,6 +692,7 @@ const users = [
}

```

🎉 CONGRATULATIONS ! 🎉

[<< 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 10](../10_Day_Sets_and_Maps/10_day_Sets_and_Maps.md) | [Day 12 >>](../12_Day_Regular_expressions/12_day_regular_expressions.md)
Loading

0 comments on commit faace4f

Please sign in to comment.