Skip to content

Instantly share code, notes, and snippets.

@shaefer
Created June 5, 2018 21:08
Show Gist options
  • Save shaefer/092772831aa6f7c276cc85b038309903 to your computer and use it in GitHub Desktop.
Save shaefer/092772831aa6f7c276cc85b038309903 to your computer and use it in GitHub Desktop.
DiceBag Phase 1
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