Double array value - Node.js Array

Node.js examples for Array:Array Value

Description

Double array value

Demo Code

Array.prototype.doubleArray = function () {
  double = [];//ww  w .  ja  v  a2  s . c om

  for( i = 0; i < this.length ; i++) {
    double.push(this[i]*2);
  }
  return double;
}

a = [1,2,3,4,5,6];
console.log(a.doubleArray());

Related Tutorials