Created
October 20, 2014 10:57
-
-
Save fmtarif/2e29770c312baa21326b to your computer and use it in GitHub Desktop.
#js return a random number from a range in javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var max = 50, | |
min = 10; | |
var random = Math.floor(Math.random() * (max-min) + min) //will return a random int within the range min to max | |
alert(random); | |
//so if min is 0 then it simply becomes | |
//Math.floor(Math.random() * max) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment