Last active
January 5, 2018 20:01
-
-
Save merryt/597d9af252ba838185a6d277b4197667 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| didUnlikelyHappen = function(){ | |
| if (Math.floor(Math.random()*10) === 2){ | |
| return true; | |
| }else{ | |
| return false; | |
| } | |
| } | |
| makePrediction = function(){ | |
| if(Math.random() > 0.5 ){ | |
| return false; | |
| }else{ | |
| return true; | |
| } | |
| } | |
| var numberRight = 0; | |
| var totalGuesses = 10000; | |
| for(var i= 0; i < totalGuesses; i++){ | |
| if(didUnlikelyHappen() === makePrediction()){ | |
| numberRight ++; | |
| } | |
| } | |
| console.log(numberRight + " out of "+ totalGuesses) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment