Skip to content

inRange ​

The inRange function checks if a number is within an inclusive range.

Syntax ​

typescript
inRange(value, min, max)

Parameters ​

NameTypeDescription
valuenumberNumber to be checked.
minnumberLower bound of the range.
maxnumberUpper bound of the range.

Return Value ​

TypeDescription
booleantrue if value is between min and max (inclusive), else false.

Examples ​

typescript
inRange(5, 1, 10); // true
inRange(0, 1, 10); // false

Notes ​

  • Throws a TypeError if any parameter is not a number.
  • Useful for validating limits and numeric constraints.

References ​

Released under the MIT License.