Created
April 4, 2017 19:33
-
-
Save kevmor11/7df3fc7a5dd98a2fcbf812bb47fff66d to your computer and use it in GitHub Desktop.
This file contains 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
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])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
broke the single responsibility principle...sorry ¯_(ツ)_/¯