Skip to content

Instantly share code, notes, and snippets.

@silianlinyi
Created January 6, 2014 07:49
Show Gist options
  • Save silianlinyi/8279550 to your computer and use it in GitHub Desktop.
Save silianlinyi/8279550 to your computer and use it in GitHub Desktop.
Returns a random integer between min and max, inclusive. If you only pass one argument, it will return a number between 0 and that number.
function ramdom(min, max) {
if (max == null) {
max = min;
min = 0;
}
return min + Math.floor(Math.random() * (max - min + 1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment