Created
June 12, 2015 08:31
-
-
Save andreasvirkus/81ca905e0646b22af27a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function rand(min, max, integer) { | |
var r = Math.random() * (max - min) + min; | |
return integer ? r|0 : r; | |
} | |
// Usage | |
console.log(rand(2,5)); // float random between 2 and 5 inclusive | |
console.log(rand(1,100,true)); // integer random between 1 and 100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment