Skip to content

Instantly share code, notes, and snippets.

@jportella93
Created November 5, 2018 21:43
Show Gist options
  • Select an option

  • Save jportella93/1df412568ecca1936c882929c5ffb52d to your computer and use it in GitHub Desktop.

Select an option

Save jportella93/1df412568ecca1936c882929c5ffb52d to your computer and use it in GitHub Desktop.
Generate random number between two numbers javascript
function generateRandom(max, min){
if (typeof max !== 'number' | typeof min !== 'number') throw new Error('max and min should be numbers')
if (min > max) throw new Error('max should be bigger than min')
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