Javascript Array fill( size, m, n )

Description

Javascript Array fill( size, m, n )


function randomNumber (m,n)
{
  m = parseInt(m);/*from w  ww  .  j av  a 2 s.c  om*/
  n = parseInt(n);
  return Math.floor( Math.random() * (n - m + 1) ) + m;
}

Array.prototype.fill = function( size, m, n )
{
 var i;
 for (i = 0;i <= size;i++) {   
  this[i] =  randomNumber(m, n);
 }

 return this;
};



PreviousNext

Related