Skip to content

Instantly share code, notes, and snippets.

@DaneSirois
Created October 4, 2016 19:00
Show Gist options
  • Save DaneSirois/244656e48bfc21ded550c34d13f68409 to your computer and use it in GitHub Desktop.
Save DaneSirois/244656e48bfc21ded550c34d13f68409 to your computer and use it in GitHub Desktop.
var numOfDice = process.argv.slice(2);
function rollDice(diceNumber) {
var diceRolls = [];
for (var i = 0; i < diceNumber; i++) {
var dice = Math.floor(Math.random() * (6 - 1 + 1) + 1)
diceRolls.push(dice);
}
return ("Rolled dice: " + diceRolls.join(", "));
}
console.log(rollDice(numOfDice));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment