๐ฉArray.reduce()
.reduce
no mutation
Description
The reduce() method applies a function against an accumulator and each value of the array (from left-to-right) to reduce it to a single value.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
Example
reduce()
reduce
method will take in reducer
function and initial value as arguments. The reducer
function can take up to 4 arguments: accumulator
, element
, index
, and array
. The reducer function will be executed for each iteration and the returned value of each iteration will be used for the next iteration.
Note
: reduce method returns a single value not an array.
Last updated