5,321
edits
(→Usage) |
(→Arrays) |
||
Line 14: | Line 14: | ||
// then the first element will be your accumulator | // then the first element will be your accumulator | ||
// I.e. the first call to your function will be (arr[0], arr[1]) | // I.e. the first call to your function will be (arr[0], arr[1]) | ||
arr.reduce((acc, x) => acc + x, 0); //6 | arr.reduce((acc, x) => acc + x, 0); // 6 | ||
</syntaxhighlight> | </syntaxhighlight> | ||