# Generate a random boolean in Javascript

javascript get random boolean

`const randomBoolean = () => Math.random() >= 0.5;`

random boolean javascript

```
console.log(Math.random() < 0.1);
console.log(Math.random() < 0.4);
console.log(Math.random() < 0.5);
console.log(Math.random() < 0.8);
console.log(Math.random() < 0.9);
```

### Output

10% probability of getting true

40% probability of getting true

50% probability of getting true

80% probability of getting true

90% probability of getting true

40% probability of getting true

50% probability of getting true

80% probability of getting true

90% probability of getting true