Skip to content

Instantly share code, notes, and snippets.

@quangnd
Last active August 5, 2016 07:53
Show Gist options
  • Save quangnd/a8f3b48ea596718ca4f3fbb89eef85b5 to your computer and use it in GitHub Desktop.
Save quangnd/a8f3b48ea596718ca4f3fbb89eef85b5 to your computer and use it in GitHub Desktop.
Get random number in Javascript
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