Here you can find the source of sum()
function extend(destination, source) { for (var property in source) { destination[property] = source[property]; }/* w ww. j a v a 2 s . c o m*/ return destination; } Array.prototype.sum = function() { var result = 0; for (var i = 0; i < this.length; i++) { result += this[i]; } }; if (!Array.prototype.indexOf) { Array.prototype.indexOf = function(elt /*, from*/) { var len = this.length >>> 0; var from = Number(arguments[1]) || 0; from = (from < 0) ? Math.ceil(from) : Math.floor(from); if (from < 0) { from += len; } for (; from < len; from++) { if (from in this && this[from] === elt) { return from; } } return -1; }; };
Array.prototype.sum = function () { var sum, i; sum = 0; for (var i = 0; i < this.length; i++) { sum += this[i]; }; return sum; console.log([1, 3, 12, 33, 2].sum());
Array.prototype.sum = function () { return this.reduce(function(a, b) { return a + b; }); }; console.log([1, 2, 3].sum());
Array.prototype.sum = function () { return this.reduce(function (value, current) { return value + current; }, 0); };
Array.prototype.sum = function () { return (!this.length) ? 0 : this.reduce((acc, value) => { return acc + value; }); };
Array.prototype.sum=function(){return this.reduce(function(s,n){return s+n})} function NumberAddition(str) { return str.replace(/[^\d]/g, ' ').split(' ').map(Number).sum(); NumberAddition(readline());
Array.prototype.sum = function() { var n = 0; this.forEach(function(e) { n += e; }); return n; };
Math.TAU = Math.PI * 2; Array.prototype.sum = function() for (var i = 0, L = this.length, sum = 0; i < L; sum += this[i++]); return sum; Array.prototype.product = function() for (var i = 0, L = this.length, product = 1; i < L; product = product * this[i++]); ...
Array.prototype.sum = function(){ return this.reduce(function(sum, item){ return sum + item; }, 0) function isInt(n){ return Number(n) === n && n % 1 === 0; function isFloat(n){ ...
Array.prototype.sum = function() { var sum = 0; this.forEach(function(k) { sum += k; }); return sum; };