Last active
May 18, 2019 02:04
-
-
Save PrimeTimeTran/fb464d174fbf57ee8868140d0e5d7c1b to your computer and use it in GitHub Desktop.
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
// 1. Get total number of dice to be rolled. | |
const numberOfDice = Math.floor((Math.random() * 20)) | |
numberOfDice // What am I? | |
// 2. Variables to store dice rolls sum & individual rolls. | |
let diceSum = 0 | |
let diceRolls = [] | |
// 3. Number of dice choosen roll a random num 1-6. | |
for(var i = 0; i < numberOfDice; i++){ | |
let diceRoll = Math.floor((Math.random() * 6)) + 1 | |
// Add to diceRolls array | |
diceRolls.push(diceRoll) | |
// Add to sum | |
diceSum += diceRoll | |
} | |
// What are we? | |
diceRolls | |
diceSum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment