const sumOfCubes = array => { return array.reduce(function(sum,value){ return sum + Math.pow(value, 3); },0) // this line } console.log(sumOfCubes([1, 5, 9]));
The second argument of the reduce function is the initial value, so for the sum it starts at 0. That's why the ,0) is there for.
,0)
2.1m questions
2.1m answers
60 comments
57.0k users