Skip to content

Instantly share code, notes, and snippets.

@adamculpepper
Last active October 10, 2018 19:42
Show Gist options
  • Save adamculpepper/e257cb1e35529c6498e2 to your computer and use it in GitHub Desktop.
Save adamculpepper/e257cb1e35529c6498e2 to your computer and use it in GitHub Desktop.
Random Number (range)
// 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