percent Chance
Return a boolean value that is true a given percentage of the time.
Math.percentChance(0)
Parameters
- percentage: a number which is the percentage chance that the returned value will be
true
. The percentage is a value beteen0
and100
.
Returns
- a boolean that is
true
for the percentage of chance given.
Example
Simulate picking the number 1
when rolling dice. Use a percentage chance to see
if your number is rolled.
let isOne = Math.percentChance(100 / 6)