Files
30-seconds-of-code/snippets/randomBoolean.md
2022-06-08 12:30:49 +03:00

435 B

title, tags, expertise, author, cover, firstSeen, lastUpdated
title tags expertise author cover firstSeen lastUpdated
Random boolean value math,random beginner chalarangelo blog_images/malibu.jpg 2021-01-20T16:20:08+02:00 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