Please enable JavaScript.
Coggle requires JavaScript to display documents.
REDUCE (reducing (single (value), elements, in, all), numbers…
REDUCE
-
numbers.reduce((accumulator, currentValue) => {return accumulator + currentValue;}, 0);
-
numbers.reduce((accumulator, currentValue) => accumulator + currentValue);
example
const array1 = [1, 2, 3, 4];
const reducer = (accumulator, currentValue) => accumulator + currentValue;
-
const array1 = [1, 2, 3, 4];
const reducer = (accumulator, currentValue) => accumulator + currentValue;
console.log(array1.reduce(reducer),5);
-
-
-