Nodejs Utililty Methods Array Square

List of utility methods to do Array Square

Description

The list of methods to do Array Square are organized into topic(s).

Method

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(){
...