randomBoolWithFactor function

bool randomBoolWithFactor([
  1. int trueFactor = 50
])

Generates a random boolean value based on the specified trueFactor. The trueFactor is a percentage value between 1 and 100 that determines the likelihood of the boolean being true.

Implementation

bool randomBoolWithFactor([int trueFactor = 50]) => trueFactor <= 0 ? false : randomInt(1, 100) <= trueFactor.clamp(1, 100);