Add randomBoolean

This commit is contained in:
Chalarangelo
2021-01-20 16:20:08 +02:00
parent ad5471a20c
commit 3cba520c4b

16
snippets/randomBoolean.md Normal file
View File

@ -0,0 +1,16 @@
---
title: randomBoolean
tags: math,random,beginner
---
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`.
```js
const randomBoolean = () => Math.random() >= 0.5;
```
```js
randomBoolean(); // true
```