You should be able to use reduce.
var sum = array.reduce(function(pv, cv) { return pv + cv; }, 0);
Source
And with arrow functions introduced in ES6, it’s even simpler:
sum = array.reduce((pv, cv) => pv + cv, 0);
You should be able to use reduce.
var sum = array.reduce(function(pv, cv) { return pv + cv; }, 0);
Source
And with arrow functions introduced in ES6, it’s even simpler:
sum = array.reduce((pv, cv) => pv + cv, 0);