Skip to content

Commit 57ab3f2

Browse files
authored
Merge pull request Asabeneh#29 from ermiaswalelgne/master
Day 5 text, typo and grammar are patched
2 parents 408bcda + 23bf1f4 commit 57ab3f2

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

05_Day/05_day_arrays.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535

3636
## Arrays
3737

38-
In contrast to variables array can store _multiple values_. Each value in an array has an _index_ and each index has _a reference in a memory address_. Each value can be accessed by using their _indexes_. The index of an array starts from _zero_ and the last element is less by one from the length of the array.
38+
In contrast to variables, an array can store _multiple values_. Each value in an array has an _index_, and each index has _a reference in a memory address_. Each value can be accessed by using their _indexes_. The index of an array starts from _zero_, and the last element is less by one from the length of the array.
3939

40-
Array is a collection of different data types which are ordered and changeable(modifiable). Allows duplicate element and different data types. An array can be empty or it may have different data type values
40+
An array is a collection of different data types which are ordered and changeable(modifiable). An array allows storing duplicate elements and different data types. An array can be empty, or it may have different data type values.
4141

4242
### How to create an empty array
4343

44-
In JavaScript we can create array in different ways. Let us different ways to create an array.
44+
In JavaScript, we can create an array in different ways. Let us different ways to create an array.
4545

4646
- Using Array constructor
4747

@@ -125,7 +125,7 @@ console.log(arr)
125125

126126
### Creating an array using split
127127

128-
As we have seen in earlier section, we can split a string at different position and we can change to an array. Let us see the examples blow.
128+
As we have seen in the earlier section, we can split a string at different positions, and we can change to an array. Let us see the examples below.
129129

130130
```js
131131
let js = 'JavaScript'
@@ -148,7 +148,7 @@ console.log(words)
148148

149149
### Accessing array items using index
150150

151-
We access each element in an array using their index. An array index start from 0. The picture below show clearly the starting of the index.
151+
We access each element in an array using their index. An array index starts from 0. The picture below clearly shows the starting of the index.
152152

153153
![arr index](../images/array_index.png)
154154

@@ -247,7 +247,7 @@ console.log(shoppingCart[lastIndex]) // -> Sugar
247247

248248
### Modifying array element
249249

250-
An array is mutable(modifiable). Once an array is created we can modify the contents or the array elements.
250+
An array is mutable(modifiable). Once an array is created, we can modify the contents of the array elements.
251251

252252
```js
253253
const numbers = [1, 2, 3, 4, 5]
@@ -283,7 +283,7 @@ console.log(countries)
283283

284284
### Methods to manipulate array
285285

286-
There are different methods to manipulate an array. These are some of the available methods to deal with arrays:_Array,length, concat, indexOf, slice, splice, join, toString, includes, lastIndexOf, isArray, fill, push, pop, shift, unshift_
286+
There are different methods to manipulate an array. These are some of the available methods to deal with arrays:_Array, length, concat, indexOf, slice, splice, join, toString, includes, lastIndexOf, isArray, fill, push, pop, shift, unshift_
287287

288288
#### Array Constructor
289289

@@ -305,13 +305,13 @@ fill: Fill all the array elements with a static value
305305
const arr = Array() // creates an an empty array
306306
console.log(arr)
307307

308-
const eightXvalues = Array(8).fill('X') // it creates eight element values
308+
const eightXvalues = Array(8).fill('X') // it creates eight element values filled with 'X'
309309
console.log(eightXvalues) // ['X', 'X','X','X','X','X','X','X']
310310

311-
const eight0values = Array(8).fill(0) // it creates eight element values
311+
const eight0values = Array(8).fill(0) // it creates eight element values filled with '0'
312312
console.log(eight0values) // [0, 0, 0, 0, 0, 0, 0, 0]
313313

314-
const four4values = Array(4).fill(4) // it creates 4 element values
314+
const four4values = Array(4).fill(4) // it creates 4 element values filled with '4'
315315
console.log(four4values) // [4, 4, 4, 4, 4, 4, 4, 4]
316316
```
317317

@@ -330,7 +330,7 @@ console.log(thirdList) // [1, 2, 3, 4, 5, 6]
330330
```js
331331
const fruits = ['banana', 'orange', 'mango', 'lemon'] // array of fruits
332332
const vegetables = ['Tomato', 'Potato', 'Cabbage', 'Onion', 'Carrot'] // array of vegetables
333-
const fruitsAndVegetables = fruits.concat(vegetables)
333+
const fruitsAndVegetables = fruits.concat(vegetables) // concatinate the two arrays
334334

335335
console.log(fruitsAndVegetables)
336336
```
@@ -345,7 +345,7 @@ Length:To know the size of the array
345345

346346
```js
347347
const numbers = [1, 2, 3, 4, 5]
348-
console.log(numbers.length) // -> 5
348+
console.log(numbers.length) // -> 5 is the size of the array
349349
```
350350

351351
#### Getting index an element in arr array
@@ -361,7 +361,7 @@ console.log(numbers.indexOf(1)) // -> 0
361361
console.log(numbers.indexOf(6)) // -> -1
362362
```
363363

364-
Check an element if it exist in an array
364+
Check an element if it exist in an array.
365365

366366
- Check items in a list
367367

@@ -393,12 +393,12 @@ if(indexOfAvocado!= -1){
393393

394394
#### Getting last index of an element in array
395395

396-
lastIndexOf:Give the position of the last item in the array. If it exist it returns the index else it returns -1.
396+
lastIndexOf: It gives the position of the last item in the array. If it exist, it returns the index else it returns -1.
397397

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

401-
console.log(numbers.lastIndexOf(2)) // -7
401+
console.log(numbers.lastIndexOf(2)) // 7
402402
console.log(numbers.lastIndexOf(0)) // -1
403403
console.log(numbers.lastIndexOf(1)) // 6
404404
console.log(numbers.lastIndexOf(4)) // 3
@@ -455,7 +455,7 @@ console.log(names.toString()) // Asabeneh,Mathias,Elias,Brook
455455

456456
#### Joining array elements
457457

458-
join:To join the elements of the array, the argument passed in the join method will be joined in the array and return as a string. By default it joins with a comma but we can pass different string parameter which can be joined between the items.
458+
join: It used to join the elements of the array, the argument passed in the join method will be joined in the array and return as a string. By default, it joins with a comma, but we can pass different string parameter which can be joined between the items.
459459

460460
```js
461461
const numbers = [1, 2, 3, 4, 5]
@@ -485,7 +485,7 @@ console.log(webTechs.join(' # ')) // "HTML # CSS # JavaScript # React # Redux #
485485

486486
#### Slice array elements
487487

488-
Slice: To cut out a multiple items in range. It takes two parameters:starting and ending position. It doesn't include the ending position
488+
Slice: To cut out a multiple items in range. It takes two parameters:starting and ending position. It doesn't include the ending position.
489489

490490
```js
491491
const numbers = [1,2,3,4,5]
@@ -498,7 +498,7 @@ Slice: To cut out a multiple items in range. It takes two parameters:starting an
498498

499499
#### Splice method in array
500500

501-
Splice: It takes three parameters:Starting position, number of times to be removed and number items to be added.
501+
Splice: It takes three parameters:Starting position, number of times to be removed and number of items to be added.
502502

503503
```js
504504
const numbers = [1, 2, 3, 4, 5];
@@ -511,7 +511,7 @@ Splice: It takes three parameters:Starting position, number of times to be remov
511511

512512
#### Adding item to an array using push
513513

514-
Push: adding item in the end. To add item to the end of an existing array we use the push method
514+
Push: adding item in the end. To add item to the end of an existing array we use the push method.
515515

516516
```js
517517
// syntax
@@ -544,7 +544,7 @@ console.log(fruits) // ['banana', 'orange', 'mango', 'lemon', 'apple', 'lime']
544544

545545
#### Removing the end element using pop
546546

547-
Pop: Removing item in the end
547+
Pop: Removing item in the end.
548548

549549
```js
550550
const numbers = [1, 2, 3, 4, 5]
@@ -555,7 +555,7 @@ console.log(numbers) // -> [1,2,3,4]
555555

556556
#### Removing an element from the beginning
557557

558-
shift: Removing one array element in the beginning of the array
558+
shift: Removing one array element in the beginning of the array.
559559

560560
```js
561561
const numbers = [1, 2, 3, 4, 5]
@@ -566,7 +566,7 @@ console.log(numbers) // -> [2,3,4,5]
566566

567567
#### Add an element from the beginning
568568

569-
unshift: Adding array element in the beginning of the array
569+
unshift: Adding array element in the beginning of the array.
570570

571571
```js
572572
const numbers = [1, 2, 3, 4, 5]
@@ -577,7 +577,7 @@ console.log(numbers) // -> [0,1,2,3,4,5]
577577

578578
#### Reversing array order
579579

580-
reverse: reverse the order of an array
580+
reverse: reverse the order of an array.
581581

582582
```js
583583
const numbers = [1, 2, 3, 4, 5]
@@ -591,7 +591,7 @@ console.log(numbers) // [1, 2, 3, 4, 5]
591591

592592
#### Sorting elements in array
593593

594-
sort: arrange array elements in ascending order. Sort takes a call back function, we wil see how we use sort with call back function in the coming sections.
594+
sort: arrange array elements in ascending order. Sort takes a call back function, we will see how we use sort with call back function in the coming sections.
595595

596596
```js
597597
const webTechs = [

0 commit comments

Comments
 (0)