Skip to content

Instantly share code, notes, and snippets.

@Angelfire
Created December 11, 2018 15:09
Show Gist options
  • Save Angelfire/5f687ab12022decb7bc41ec459f344d3 to your computer and use it in GitHub Desktop.
Save Angelfire/5f687ab12022decb7bc41ec459f344d3 to your computer and use it in GitHub Desktop.
Get a random integer, between two integers
// https://stackoverflow.com/questions/4959975/generate-random-number-between-two-numbers-in-javascript
getRandomNumber = function(min, max) {
min = typeof(min) === 'number' && min % 1 === 0 ? min : 0;
max = typeof(max) === 'number' && max % 1 === 0 ? max : 0;
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