Skip to content

Instantly share code, notes, and snippets.

@sayyedhammadali
Created October 3, 2021 09:40
Show Gist options
  • Save sayyedhammadali/b8620d27813aca0ad46ede2f08a1dbd2 to your computer and use it in GitHub Desktop.
Save sayyedhammadali/b8620d27813aca0ad46ede2f08a1dbd2 to your computer and use it in GitHub Desktop.
Get a random boolean (true/false)
const randomBoolean = () => Math.random() >= 0.5;
console.log(randomBoolean());
// Result: a 50/50 change on returning true of false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment