Skip to content

Instantly share code, notes, and snippets.

@auxiliary-character
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save auxiliary-character/babb692d6ea0c4f8a38c to your computer and use it in GitHub Desktop.
Save auxiliary-character/babb692d6ea0c4f8a38c to your computer and use it in GitHub Desktop.
Dice
function getRandomInt (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function die(sides){
return getRandomInt(1,sides);
}
function dice(dice,sides){
var total = 0;
for(var i=0;i<dice;i++){
total+=die(sides);
}
return total;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment