Version: v0.8.1 - Beta.  We welcome contributors & feedback.

Number.clampMax

clampMax($max) -> number

Description

Make sure the number is not higher than $max.

If it is higher than $max, returns $max. Otherwise, it returns the number.

$num = 133
$num.clampMax(100) //= 100

$num = 88
$num.clampMax(100) //= 88

$num = -5
$num.clampMax(0) //= 0

See Also