Created
June 21, 2017 00:42
-
-
Save maburdi94/4fa7bd49b3dd008df366bb65a1274983 to your computer and use it in GitHub Desktop.
Function to produce random boolean value with retries
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
function _randomBool(oddsOfTrue = 1) { | |
let r; while (!(r = !~~(Math.random() * 2)) && --oddsOfTrue > 0); | |
return r; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment