Node.js examples for Array:Sum
Sum all elements in an array
if (typeof Array.prototype.sum != 'function') { Array.prototype.sum = function() { var result = 0; $.each(this, function(index, num) { result += num;//w w w. jav a2 s . c o m }); return result; }; }