Skip to content

Instantly share code, notes, and snippets.

@dylants
Created April 3, 2014 16:31
Show Gist options
  • Save dylants/9957843 to your computer and use it in GitHub Desktop.
Save dylants/9957843 to your computer and use it in GitHub Desktop.
Generate a number between low and high
/**
* Generates a number between low and high
*
* @param {Number} low The lower bound for the number generator
* @param {Number} high The upper bound for the number generator
* @return {Number} A number between low and high
*/
function generateNum(low, high) {
return Math.floor(Math.random() * ((+high) - (+low) + 1)) + (+low);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment