Created
April 24, 2019 08:10
-
-
Save mebtte/26ccd015665eb58cfc72d5a11de2d546 to your computer and use it in GitHub Desktop.
Get a random integer.
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
| /** | |
| * Get a random integer. | |
| * @author mebtte<[email protected]> | |
| * @param {Number} [min] Minimum integer, default `0`. | |
| * @param {Number} [max] Maximum integer, default `1`. | |
| * @return {Number} A random integer between `min` and `max` that include `min` but do not include `max`. | |
| */ | |
| function getRandomInteger(min = 0, max = 1) { | |
| return Math.floor(min + Math.random() * (max - min)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment