Skip to content

Commit

Permalink
array items using index examples fix
Browse files Browse the repository at this point in the history
  • Loading branch information
npnjuguna authored Jan 6, 2020
1 parent d16e822 commit e8765bd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions 05_Day/05_day_arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ let lastFruit = fruits[3]
console.log(lastFruit) // lemon
// Last index can be calculated as follows

let lastIndex = len(fruits) - 1
let lastIndex = fruits.length - 1
lastFruit = fruits[lastIndex]
console.log(lastFruit) // lemon
```
Expand All @@ -179,7 +179,7 @@ console.log(numbers[0]) // -> 0
console.log(numbers[5]) // -> 100

let lastIndex = numbers.length - 1;
console.log(numbers[lastIndex]) -> 100
console.log(numbers[lastIndex]) // -> 100
```

```js
Expand All @@ -199,7 +199,7 @@ console.log(webTechs[0]) // -> HTML
console.log(webTechs[6]) // -> MongoDB

let lastIndex = webTechs.length - 1
console.log(webTechs[lastIndex]) -> MongoDB
console.log(webTechs[lastIndex]) // -> MongoDB
```

```js
Expand All @@ -222,7 +222,7 @@ console.log(countries[0]) // -> Albania
console.log(countries[10]) // -> Kenya

let lastIndex = countries.length - 1;
console.log(countries[lastIndex]) -> // Kenya
console.log(countries[lastIndex]) // -> Kenya
```

```js
Expand All @@ -242,7 +242,7 @@ console.log(shoppingCart[0]) // -> Milk
console.log(shoppingCart[7]) // -> Sugar

let lastIndex = shoppingCart.length - 1;
console.log(shoppingCart[lastIndex]) -> // Sugar
console.log(shoppingCart[lastIndex]) // -> Sugar
```

### Modifying array element
Expand Down Expand Up @@ -721,4 +721,4 @@ const webTechs = [
🎉 CONGRATULATIONS ! 🎉
[<< Day 4](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/04_Day/04_day_conditionals.md) | [Day 6 >>](#)
[<< Day 4](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/04_Day/04_day_conditionals.md) | [Day 6 >>](#)

0 comments on commit e8765bd

Please sign in to comment.