var arr = [1, 3, 5, 7, 9];
arr.reduce(function (x, y) {
return x + y;
}); // 25
function product(arr) {
result=arr.reduce(function (x, y) {
return x + y;
});
return result;
}
product(arr);
Array for a sum, using reduce implementation
Guess you like
Origin blog.csdn.net/luyundesign/article/details/104016684
Recommended
Ranking