Created
January 4, 2018 13:52
-
-
Save wiyoe/b4fb09d4e63fb637b6227deb9c28c82e to your computer and use it in GitHub Desktop.
Javascript random numbers.
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
| // Naive utility method | |
| function getRandomNumber(min, max){ | |
| return Math.floor(Math.random() * (max - min + 1)) + min; | |
| } | |
| getRandomNumber(15, 20); | |
| // Lodash | |
| _.random(15, 20); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment