Skip to content

Commit

Permalink
small change to the array method files
Browse files Browse the repository at this point in the history
  • Loading branch information
codebyuma committed Jan 10, 2018
1 parent 04740eb commit 0472189
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions resources/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ let myListOfAges = [22, 12, 43, 44, 22, 54, 16, 87, 12];
let myListOfOldEnoughAges = myListOfAges.filter(eachAge => eachAge >= 18);
```

- `filter` exists as a method on all arrays, it takes one uncalled function as an argument
- This uncalled function is called for each item in the array, as filter iterates over each item
- `filter` exists as a method on all arrays, it takes one unnamed function (also known as an anonymous function) as an argument
- This anonymous function is called for each item in the array, as filter iterates over each item
- This function is provided the value currently being iterated over as the first parameter, in the above
case, that means that `eachAge` represents `22` the first time it is called, then `12`, and then `43` and so on.
- This function expects either a `true` or a `false` to be returned inside of it.
Expand Down
4 changes: 2 additions & 2 deletions resources/map.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ let listOfPetAgesInHumanYears = listOfPets.map(function(pet) {
});
```

- `map` exists as a method on all arrays, it takes one uncalled function as an argument
- This uncalled function is called for each item in the array, as map iterates over each item
- `map` exists as a method on all arrays, it takes one (also known as an anonymous function) function as an argument
- This anonymous function is called for each item in the array, as map iterates over each item
- This function is provided the value currently being iterated over as the first parameter, in the above
case, that means that `pet` represents `{type: 'Dog', age: 5}` the first time it is called, then `{type: 'Cat', age: 11}` the second time,
and then `{type: 'Dog', age: 9}` the third.
Expand Down
4 changes: 2 additions & 2 deletions resources/reduce.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const soldItems = [
const totalSales = soldItems.reduce((accumulator, nextItem) => accumulator + nextItem.price, 0);
```

- `reduce` exists as a method on all arrays, it takes one uncalled function as the first argument
- This uncalled function is called for each item in the array, as reduce iterates over each item
- `reduce` exists as a method on all arrays, it takes one unnamed function (also known as an anonymous function) as the first argument
- This anonymous function is called for each item in the array, as reduce iterates over each item
- It also takes an optional second parameter, which will act as the first value
- In the above example, `0` is the optional second parameter
- The first time reduce is called, `accumulator` is equal to `0`
Expand Down

0 comments on commit 0472189

Please sign in to comment.