Created
December 11, 2018 15:09
-
-
Save Angelfire/5f687ab12022decb7bc41ec459f344d3 to your computer and use it in GitHub Desktop.
Get a random integer, between two integers
This file contains 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
// 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