Javascript Array range(from, to)

Description

Javascript Array range(from, to)


"use strict";/*  w  w  w .jav  a  2  s .  c  om*/

Array.prototype.range = function(from, to) {
  var i = from, result = [];

  while(i <= to) {
    result.push(i);
    i++;
  }
  return result;
};

Javascript Array range(from, to)

Array.prototype.range = function(from, to){
  var arr = [];/*from   w w  w  .  jav a2s . co  m*/
  while(from < to + 1){
    arr.push(from);
    from++;
  }
  return arr;
};

Javascript Array range(from, to)

Array.prototype.range = function(from, to) {
  var result = []
  while (from <= to)
    result.push(from++)//from w ww. j  a va 2 s.c o  m
  return result
}

Javascript Array range(from, to)

"use strict";//from   w  w  w . j  a  v  a  2s  .  c o m

Array.prototype.range = function(from, to) {
  var result = [];
  while(from <= to) {
    result.push(from);
    from = from + 1;
  }
  return result;
};

Javascript Array range(from, to)

Array.prototype.range = function(from, to) {
 var i, result = [];
 for (i = from; i<= to; i++) {
  result.push(i);/*from w  w w . j  av a  2 s .c  om*/
 }
 return result;
};

console.log([].range(1, 10));



PreviousNext

Related