Last active
July 1, 2016 14:22
-
-
Save BenBestmann/56bd2fbf960e83a32d3cea7219eca85c to your computer and use it in GitHub Desktop.
Let some event happen by a given probability. Will return true or false given a certain probability in percent (1-99).
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
function takeChance(probability) { | |
probability = probability / 100; | |
return !!probability && Math.random() <= probability; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment