Created
November 12, 2012 23:23
-
-
Save SapientBoston/4062757 to your computer and use it in GitHub Desktop.
JavaScript: 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
| /** | |
| * Generates a random interger between two given values | |
| * | |
| * @private | |
| * @param {Number} from Integer representing the lower bound of the range | |
| * @param {Number} to Integer representing the upper bound of the range | |
| * @return {Number} Randomly generated integer | |
| */ | |
| function random(from, to) { | |
| return Math.floor(Math.random() * (to - from + 1) + from); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment