Created
May 19, 2018 16:54
-
-
Save ArupSen/5f78c075bcb1eb20d1732387c5a75da3 to your computer and use it in GitHub Desktop.
Basic js function to roll a pair of dice
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(){ | |
var output = []; | |
var die1 = Math.floor(Math.random() * 6); | |
var die2 = Math.floor(Math.random() * 6); | |
// need to add 1 to avoid zero based output | |
output.push(die1 + 1); | |
output.push(die2 + 1); | |
return output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment