Last active
August 29, 2015 14:01
-
-
Save auxiliary-character/babb692d6ea0c4f8a38c to your computer and use it in GitHub Desktop.
Dice
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
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