Skip to content

Instantly share code, notes, and snippets.

@azharkhan
Created March 26, 2015 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azharkhan/44833befc17fe64bedd3 to your computer and use it in GitHub Desktop.
Save azharkhan/44833befc17fe64bedd3 to your computer and use it in GitHub Desktop.
Random Number Generator
/**
* Returns a random number between min and max
*/
function getRandomArbitary (min, max) {
return Math.random() * (max - min) + min;
}
/**
* Returns a random integer between min and max
* Using Math.round() will give you a non-uniform distribution!
*/
function getRandomInt (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment