Created
January 24, 2017 20:30
-
-
Save ValeryToda/fbf1de017f91c0ec3da04116c5ccf8b5 to your computer and use it in GitHub Desktop.
Random Integer generator (Typescript)
This file contains 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
/** | |
* generate a random integer between min and max | |
* @param {Number} min | |
* @param {Number} max | |
* @return {Number} random generated integer | |
*/ | |
randomInt(min, max){ | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} |
A better version:
(added types, made a better description)
https://gist.github.com/rodrigograca31/3c6cd8b95b7d7749cac96136211c5d78
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, just what I needed for the game I'm making.