Skip to content

Instantly share code, notes, and snippets.

@maburdi94
Created June 21, 2017 00:42
Show Gist options
  • Save maburdi94/4fa7bd49b3dd008df366bb65a1274983 to your computer and use it in GitHub Desktop.
Save maburdi94/4fa7bd49b3dd008df366bb65a1274983 to your computer and use it in GitHub Desktop.
Function to produce random boolean value with retries
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