isBetween()
isBetween(
bounds
): (c
) =>boolean
Creates a predicate function that determines if a number is between two bounds (inclusive).
Parameters
bounds
[number
, number
]
The tuple containing the lower and upper bounds (order doesn't matter)
Returns
(
c
):boolean
Parameters
c
number
Returns
boolean
Remarks
- Pure function with no side effects
- Inclusive on both ends (
>=
lower bound and<=
upper bound) - Automatically sorts bounds, so order doesn't matter in the tuple
Example
const isValidScore = isBetween([0, 100]);
isValidScore(89); // true
isValidScore(150); // false
isValidScore(0); // true (inclusive)
// Order doesn't matter
const isInRange = isBetween([100, 0]);
isInRange(50); // true