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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user