Here you can find the source of square()
// http://www.codewars.com/kata/525d50d2037b7acd6e000534/train/javascript Array.prototype.square = function () { return this.map(function (e) { return e * e; });/*from ww w. j a va 2s.c o m*/ };
Array.prototype.square = function(){ return Array.from(this, x => x * x)
Array.prototype.square = function(){ return this.map((element) => Math.pow(element,2));} == Array.prototype.cube = function(){ return this.map((element) => Math.pow(element,3));}
Array.prototype.square = function () { return this.map(function(n) { return n * n; });
Array.prototype.square = function () { return this.map((item) => { return Math.pow(item, 2); }); };
Array.prototype.square = function(){ return this.map(function(e){ return (e * e); }); }; Array.prototype.cube = function(){ return this.map(function(e){ return (e * e * e); }); ...
Array.prototype.square = function (){ var result = this.map(function(v){ return v*v; }); return result; }; Array.prototype.cube = function (){ var result = this.map(function(v){ return v*v*v; ...
Array.prototype.square = function () { return this.map(elem => elem*elem); } Array.prototype.cube = function() { return this.map(elem => Math.pow(elem, 3)); } Array.prototype.average = function () { return this.length > 0 ? this.reduce((a,b) => a+b) / this.length : NaN; } Array.prototype.sum = function () { return this.reduce((a,b) => a+b); } Array.prototype.even = function () { return this.filter(elem => elem % 2 === 0); } Array.prototype.odd = function () { return this.filter(elem => elem % 2 > 0); }