Skip to content

Instantly share code, notes, and snippets.

@ArupSen
Created May 19, 2018 16:54
Show Gist options
  • Save ArupSen/5f78c075bcb1eb20d1732387c5a75da3 to your computer and use it in GitHub Desktop.
Save ArupSen/5f78c075bcb1eb20d1732387c5a75da3 to your computer and use it in GitHub Desktop.
Basic js function to roll a pair of dice
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