Last active
October 24, 2021 13:44
-
-
Save rameshbaskar/2507040c85932fa578a6924efaca35ff 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
// a refValue of 0.5 will generate equal amount of true and false | |
// a refValue greater than 0.5 will generate more true values | |
// a refValue less than 0.5 will generate more false values | |
const randomBoolean = (positiveBias = false) => { | |
const refValue = positiveBias ? 0.8 : 0.5; | |
return Math.random() < refValue; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment