How to generate random numbers in Javascript -
possible duplicate:
generating random numbers in javascript
hi..
i want generate random numbers (integers) in javascript within specified range. ie. 101-999. how can that. math.random() function supports range parameters ?
the function below takes min , max value (your range).
function randomxtoy(minval,maxval) { var randval = minval+(math.random()*(maxval-minval)); return math.round(randval); }
use:
var random = randomxtoy(101, 999);
hope helps.
Comments
Post a Comment