// 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;
}
Source:
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/random
// Using Math.round() will give you a non-uniform distribution!
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
Source:
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/random
No comments:
Post a Comment