getRandomBoolean
Generates a random boolean value with equal probability. Uses Math.random() with 0.5 threshold to provide true/false values with approximately 50% probability each.
Signature
const getRandomBoolean: () => boolean
Returns
Boolean value (true or false with equal likelihood)
Examples
Boolean generation
import { getRandomBoolean } from '@winglet/common-utils';
console.log(getRandomBoolean()); // true or false
// Usage in conditional logic
if (getRandomBoolean()) {
console.log('Random condition met!');
}
Playground
import { getRandomBoolean } from '@winglet/common-utils'; console.log(getRandomBoolean()); // true or false // Usage in conditional logic if (getRandomBoolean()) { console.log('Random condition met!'); }