Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Random number between -10 and 10 in JavaScript [duplicate]

Possible Duplicate:
Generating random numbers in Javascript

How do I get a random number between −10 and 10 in JavaScript?

like image 476
coure2011 Avatar asked Aug 29 '10 09:08

coure2011


2 Answers

var min = -10; var max = 10; // and the formula is: var random = Math.floor(Math.random() * (max - min + 1)) + min; 
like image 109
Darin Dimitrov Avatar answered Oct 02 '22 01:10

Darin Dimitrov


jQuery: $.randomBetween(minValue, maxValue);

like image 36
Akyegane Avatar answered Oct 02 '22 03:10

Akyegane



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!