quote:
Originally posted by CookieRevised
That will not return a number in the range 1 to 100... It will return a random number from 0 to 99.
To return a number in the range 1 to 100, you'll need:
Math.floor((100 - 1 + 1) * Math.random() + 1);
or
Math.floor(Math.random() * 100 + 1);
quote:
Math.floor((100 - 1 + 1) * Math.random() + 1);
equals
Math.floor(100 * Math.random() + 1);
which is about the same as
quote:
Math.floor(Math.random() * 100 + 1);
both will do the job, but... I didn't expect you to be this sloppy cookie, in your average posts you wouldn't use -1+1...
getting sleepy??