Increments and multiply all elements in the array and returns - Node.js Array

Node.js examples for Array:Array Operation

Description

Increments and multiply all elements in the array and returns

Demo Code


Array.prototype.increment = function(num)

{

    for(i=0;i<this.length;i++)

        this[i]+=num;//w ww  .  j av a2 s  .  c  om

    return this;

};



Array.prototype.mult = function(num)

{

    for(i=0;i<this.length;i++)

        this[i]=this[i]*num;

    return this;

};

Related Tutorials