Created
January 6, 2014 07:49
-
-
Save silianlinyi/8279550 to your computer and use it in GitHub Desktop.
Returns a random integer between min and max, inclusive. If you only pass one argument, it will return a number between 0 and that number.
This file contains 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
function ramdom(min, max) { | |
if (max == null) { | |
max = min; | |
min = 0; | |
} | |
return min + Math.floor(Math.random() * (max - min + 1)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment