Skip to content

Instantly share code, notes, and snippets.

@potatowave
Forked from DaneSirois/RollingDice.js
Created October 4, 2016 19:05
Show Gist options
  • Save potatowave/2752b908e9cfb09a779bc4a444b1ec6b to your computer and use it in GitHub Desktop.
Save potatowave/2752b908e9cfb09a779bc4a444b1ec6b 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