Anki flashcards
1. The Array#forEach accepts a function as an argument. What arguments can the function that is passed into Array#forEach accept?
- The function that is passed into Array#forEach may accept the current element, index, and array.
2. What two arguments does the Array#reduce method accept?
- The Array#reduce method accepts a function as it’s first argument and a value to be used as the initial accumulator as an optional second argument.
3. The Array#reduce method accepts a function as an argument. What arguments should the function that is passed into Array#reduce accept?
- The function that is passed should accept the current accumulator and current element as its arguments.
4. The Array#filter method accepts a function as an argument. What type of data should the function that is passed into Array#filter return?
- The function that is passed into Array#filter should return boolean.
5. Describe what the Array#map method does.
- The Array#map method accepts a function as an argument returns a new array containing the results of calling that function on each element of the original array.
6. Describe what the Array#filter does.
- The Array#filter method accepts a function as an argument and returns a new array containing elements of the original array that result in
true
when passed into the function.