Last active
April 29, 2016 13:56
-
-
Save bronzehedwick/688b8727c41cec06bb92 to your computer and use it in GitHub Desktop.
Random whole number generator.
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
/** | |
* Returns a random number between min and max, rounded to the nearest whole number. | |
* @param {number} min is the lowest amount possible to return. | |
* @param {number} max is the highest amount possible to return. | |
* @returns {number} a random number between min and max. | |
*/ | |
let random = (min, max) => Math.round(Math.random() * (max - min) + min); |
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
/** | |
* Returns a random number between min and max, rounded to the nearest whole number. | |
* @param {number} min is the lowest amount possible to return. | |
* @param {number} max is the highest amount possible to return. | |
* @returns {number} a random number between min and max. | |
*/ | |
function random(min, max) { | |
return Math.round(Math.random() * (max - min) + min); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment