Range of numbers in math.random()

how do you specify the range of numbers in in math.random()?
thx

Math.random()*yourNumberHere;

:wink:

or

Math.floor(Math.random()*maxNumber+minNumber)

:slight_smile:

shouldn’t it be

minNumber+Math.random()*(maxNumber-minNumber);

ahmed?

oops

yeah :blush:

:stuck_out_tongue: :beam:

Ive always done it Math.floor(Math.random()*(high-low))+low

Well… I guess we have a thread that shows a whole bunch of different ways to approach the same thing :stuck_out_tongue:

thx guys

no problem. =)

Math.round(Math.random());

will give 0 or 1 every time.

that can be useful sometimes.