Files
30-seconds-of-code/js/s/random-boolean.md
Angelos Chalaris 5c913d20bd Reorganize snippets
2023-05-03 21:19:02 +03:00

400 B

title, type, language, tags, author, cover, dateModified
title type language tags author cover dateModified
Random boolean value snippet javascript
math
random
chalarangelo malibu 2021-01-20T16:20:08+02:00

Generates a random boolean value.

  • Use Math.random() to generate a random number and check if it is greater than or equal to 0.5.
const randomBoolean = () => Math.random() >= 0.5;
randomBoolean(); // true