/math/clampPercentage
stdClamps the given value to the [0, 100] range.
Type signature
(x: number) => number
Examples
clampPercentage(50);
// ⇒ 50
Try in REPL
clampPercentage(-50);
// ⇒ 0
Try in REPL
clampPercentage(150);
// ⇒ 100
Try in REPL
Questions
- How to enforce a percentage be between 0% and 100%?