Skip to content

Instantly share code, notes, and snippets.

@kevmor11
Created April 4, 2017 19:33
Show Gist options
  • Save kevmor11/7df3fc7a5dd98a2fcbf812bb47fff66d to your computer and use it in GitHub Desktop.
Save kevmor11/7df3fc7a5dd98a2fcbf812bb47fff66d to your computer and use it in GitHub Desktop.
function rollDice (rolls) {
var result = "Rolled " + rolls + " dice: "
for (var i = 0; i < rolls; i++) {
var rollNum = Math.floor((Math.random(rolls)*6)+1);
if (i < rolls - 1) {
result += (rollNum + ", ");
} else {
result += rollNum;
}
}
return result;
};
console.log(rollDice(process.argv[2]));
@kevmor11
Copy link
Author

kevmor11 commented Apr 4, 2017

broke the single responsibility principle...sorry ¯_(ツ)_/¯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment