randomize()

function randomize(limit){
  var a = Math.pow(10, String(limit).length); 
  var readyNumber = Math.floor(Math.random()*a);
  if(readyNumber>=limit){
    return randomize(limit);
  } else {
    return readyNumber;
  }
}
Example:
var randomNumber = randomize(44);
document.write("Random number: "+randomNumber);

Description

Generates random number with appointed limit.

Details

Double click on the code to select all.

 

;