Skip to content

Instantly share code, notes, and snippets.

@merryt
Last active January 5, 2018 20:01
Show Gist options
  • Select an option

  • Save merryt/597d9af252ba838185a6d277b4197667 to your computer and use it in GitHub Desktop.

Select an option

Save merryt/597d9af252ba838185a6d277b4197667 to your computer and use it in GitHub Desktop.
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