Created
June 5, 2018 21:08
-
-
Save shaefer/092772831aa6f7c276cc85b038309903 to your computer and use it in GitHub Desktop.
DiceBag Phase 1
This file contains 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
export const d6 = () => { | |
return rollDice(1, 6); | |
} | |
export const rollDice = (numOfDice, numOfSides) => { | |
let total = 0; | |
for(let i = 1;i <= numOfDice;i++) { | |
total += Math.floor(Math.random() * numOfSides) + 1; | |
} | |
return total; | |
} | |
const DiceBag = { | |
d6: d6, | |
rollDice: rollDice | |
}; | |
export default DiceBag; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment