Created
November 5, 2018 21:43
-
-
Save jportella93/1df412568ecca1936c882929c5ffb52d to your computer and use it in GitHub Desktop.
Generate random number between two numbers javascript
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 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