Skip to content

Instantly share code, notes, and snippets.

@Randgalt
Last active December 28, 2016 17:14
Show Gist options
  • Save Randgalt/9bd1de087d40b7ee9b10f2e6fec728e8 to your computer and use it in GitHub Desktop.
Save Randgalt/9bd1de087d40b7ee9b10f2e6fec728e8 to your computer and use it in GitHub Desktop.
var wouldWinIfSwitch = 0;
var wouldLoseIfSwitch = 0;
var gameQty = 0;
function runGame() {
var prizeDoor = Math.floor(3 * Math.random());
var guessDoor = Math.floor(3 * Math.random());
var firstGuessIsRight = (guessDoor === prizeDoor);
if ( firstGuessIsRight ) {
++wouldLoseIfSwitch;
} else {
++wouldWinIfSwitch;
}
++gameQty;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment