Skip to content

Instantly share code, notes, and snippets.

@brazilnut2000
Created February 1, 2018 22:50
Show Gist options
  • Save brazilnut2000/211b3b71241ce0bfe7c69f345de90d36 to your computer and use it in GitHub Desktop.
Save brazilnut2000/211b3b71241ce0bfe7c69f345de90d36 to your computer and use it in GitHub Desktop.
Get a random number between 0 and whatever upper-range you specify
function randomNumber(range) {
return Math.round(Math.random() * range);
}
// Usage:
console.log(`This is a random number from 0 to 20: ${randomNumber(20)}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment