Published
- 1 min read
random boolean javascript
The solution for this is noted below
random boolean javascript
Solution
console.log(Math.random() < 0.1) //10% probability of getting true
console.log(Math.random() < 0.4) //40% probability of getting true
console.log(Math.random() < 0.5) //50% probability of getting true
console.log(Math.random() < 0.8) //80% probability of getting true
console.log(Math.random() < 0.9) //90% probability of getting true
Try other methods by searching on the site. That is if this doesn’t work