Update 01_loop_sum_reduce_version.js (#232)

the first parameter of the reduce function is `previousValue` and the second parameter is `currentValue` so these parameter names need to be fixed.
This commit is contained in:
David Choi
2022-11-18 13:48:41 -08:00
committed by GitHub
parent 308148653a
commit 75e8e8cd9e

View File

@@ -3,6 +3,6 @@
* @param {Array} array Array of numbers
* @returns {number} Sum of the numbers
*/
const sumReduce = array => array.reduce((curr, prev) => curr + prev);
const sumReduce = array => array.reduce((prev, curr) => prev + curr);
console.log(sumReduce([1, 2, 3, 4])); // 10