Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions resources/array-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/array-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/array-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