The _.inRange
method from lodash library checks if a given number is within the specified range. It takes three arguments: the number to check, the start of the range, and the end of the range.
Here is an example usage:
index.tsx178 chars6 lines
In the above example, we have used _.inRange
to check whether the number 3 falls within the ranges [1, 5] and [4, 6]. The function returns true
for both ranges. We have also checked if the number 1 falls within the range [2, 4], which returns false
.
Note that _.inRange
is a part of the lodash library, so we need to import it in our code before using it as shown in the example.
gistlibby LogSnag