Skip to content

Instantly share code, notes, and snippets.

Created December 21, 2018 13:14
What would you like to do?
Random integer between min, max values
* Using Math.round() results in an uneven distribution, as mentioned here...
function randomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(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