Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Javascript — random number in a specific range

View random.js
1 2 3 4 5 6 7 8 9
// @return [float] a random number between min and max
function getRandom(min, max) {
return Math.random() * (max - min) + min;
}
 
// @return [integer] a random int between min and max
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
Something went wrong with that request. Please try again.