Last active
August 5, 2016 07:53
-
-
Save quangnd/a8f3b48ea596718ca4f3fbb89eef85b5 to your computer and use it in GitHub Desktop.
Get random number 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
function getRandomArbitrary(min, max) { | |
return Math.random() * (max - min) + min; | |
} | |
function getRandomInt(min, max) { | |
return Math.floor(Math.random() * (max - min + 1) + min); | |
} | |
function getRandomBetweenZeroAndOne() { | |
return Math.round(Math.random()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment