Last active
August 29, 2018 20:50
-
-
Save hperrin/58c2cfcb065b84992644f1637bb997bb to your computer and use it in GitHub Desktop.
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
// Returns true about 50% of the time, false about 50% of the time. | |
export default const maybe = () => Math.random() < .5; | |
// This should be closer to .5 the more iterations you run. | |
export const tester = iterations => { | |
let yes = 0; | |
for (let i = 0; i < iterations; i++) maybe() && yes++; | |
return yes/iterations; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment