diff --git a/resources/array-filter.md b/resources/array-filter.md index 7ec61aa..03caf93 100644 --- a/resources/array-filter.md +++ b/resources/array-filter.md @@ -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. diff --git a/resources/array-map.md b/resources/array-map.md index 86ad6aa..67a5011 100644 --- a/resources/array-map.md +++ b/resources/array-map.md @@ -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. diff --git a/resources/array-reduce.md b/resources/array-reduce.md index 80b3990..2a35e42 100644 --- a/resources/array-reduce.md +++ b/resources/array-reduce.md @@ -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`