List of utility methods to do Array Square
square()Array.prototype.square = function(){ var newArr = []; for (var i of this){ newArr.push(i*i); return newArr; }; | |
square()Array.prototype.square = function(){ return this.map(x=>Math.pow(x,2)) == Array.prototype.cube = function(){ return this.map(x=>Math.pow(x,3)) == Array.prototype.sum = function(){ ... |