Last active
April 25, 2017 23:34
-
-
Save kuon/a655d6fd9482297f0baa4c5448f4a696 to your computer and use it in GitHub Desktop.
Random int
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
// Generates a random int within a and b inclusive | |
function randomIntWithinRange(a, b) { | |
var range = a - b | |
var random = Math.random() * range | |
return a - Math.round(random) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment