js array reduce

1
2
3
4
5
6
7
8
9
var numbers = [15.5, 2.3, 1.1, 4.7];
function getSum(total, num) {
return total + Math.round(num);
}
function myFunction(item) {
var a = numbers.reduce(getSum , 0);
console.log(a)
}
myFunction();
1
2
3
4
5
6
7
8
9
var numbers = [15.5, 2.3, 1.1, 4.7];
function getSum(total, num) {
return total + Math.round(num);
}
function myFunction(item) {
var a = numbers.reduce(getSum);
console.log(a)
}
myFunction();