range

The Math.range() method will check that the specified value lies between the lower and upper bounds specified, and if not, will return the nearest value that would be in-range.

Syntax

Math.range(value, start, end)

Returns

the nearest value that would be in-range.

Parameters

value (int/float)
value to constrain
start (int/float)
lower limit
end (int/float)
upper limit (inclusive)