Slide 4
Slide 4 text
JS array methods we need to know
• map(fn) - fn will be called for each element of the array with args:
(currentValue, index, array) and the returned value will be the new
element in the result array.
• filter(fn) - fn will be called for each element and it needs to return true if
the current value should be added to the result array and false
otherwise.
• reduce(accFn, acc) - accFn will be called for each element of the array
with argumenst (accumulator, currentValue, index). If its the first call
accumulator will be acc from the reduce call. Otherwise it will be the
previously returned result from the accFn.