JavaScript expression to generate a 5-digit number in every case
if you want to generate say a zipcode, and don't mind leading zeros as long as it's 5 digits you can use:
(""+Math.random()).substring(2,7)
What about:
Math.floor(Math.random()*90000) + 10000;
Yes, you can create random numbers in any given range:
var min = 10000;
var max = 99999;
var num = Math.floor(Math.random() * (max - min + 1)) + min;
Or simplified:
var num = Math.floor(Math.random() * 90000) + 10000;