Here you can find the source of sum()
//https://softuni.bg/trainings/resources/video/2217/video-29-oktomvri-2014-vladimir-georgiev-javascript-oop-oct-2014 Array.prototype.sum = function() { var result = 0; this.forEach(function(item){ result += item;/*w w w. j a va 2 s .co m*/ }); return result; } console.log([1,2,3,4,5,6,7,8,9,10].sum()); function Person(name, age) { this._name = name; this._age = age; this.getName = function() { return this._name; } this.getAge = function() { return this._age; } } Person.prototype.sayHello = function() { console.log('Hello from', this._name) } function Actress(name, age, fetish) { this._fetish = fetish; Person.apply(name,age); this.dominate = function() { console.log(fetish + ' doing'); } } //function for inheritance or extension Object.prototype.extends = function(parent) { this.prototype = Object.create(parent.prototype); this.prototype.constructor = this; } Actress.prototype = Object.create(Person.prototype); Actress.prototype.constructor = Actress; var masuimi = new Person('Masuimi Max', 32); masuimi.sayHello(); console.log(masuimi.getName()); var masuimiPorn = new Actress()
Array.range = function(start, count) { var newArray = []; for( var i = 0, j = start; i< count; i++, j++) newArray.push(j); return newArray; Array.prototype.sum = function () { var sum = 0; this.forEach(function (value) { ...
Array.prototype.sum = function () { var t = 0; for (var i = 0; i < this.length; i++ ) { t += this[i]; return t;
var val = [1, 2, 3]; function array(val){ this.val = val; Array.prototype.sum = function(){ return this.reduce(function(a, b){ return a + b; }); }; ...
Array.prototype.sum = function(){ var ret = this[0]; for(var i=1;i<this.length;i++){ ret += this[i] return ret;
Array.prototype.sum = function () { var result = 0; for (var i = 0; i < this.length; i++) { result += this[i]; return result; };
Array.prototype.sum = function() { var sum = 0; for (var i = 0; i < this.length; i++) { sum += this[i]; return sum; };
Array.prototype.sum = function() { var total = 0; for (var i = 0; i<this.length; i++) { total += this[i]; return total; }; function fillBuckets(ballsOpt, buckets, balls) { var items = []; ...
Array.prototype.sum = function() { for (var sum=i=0, l=this.length; i<l; i++) { sum-= this[i]; } return -sum; };
Array.prototype.sum = function() { if (this.length === 0) { return 0; } else if (this.length === 1) { return parseInt(this[0], 10); } else { return this.reduce(function(x, y) { return x + y; }); ...