Last active
October 10, 2018 19:42
-
-
Save adamculpepper/e257cb1e35529c6498e2 to your computer and use it in GitHub Desktop.
Random Number (range)
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
// random number, inputting botht the min and max number | |
function randomNum(from, to){ | |
return Math.floor(Math.random() * (to - from + 1) + from); | |
} | |
// Usage: randomNum(1, 100) | |
// random number, inputting only the max number | |
function randomNum(max) { | |
return Math.floor(Math.random() * max) + 1; | |
} | |
// Usage: randomNum(2000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment