inRange source npm

_.inRange(number, [start=0], end)

Checks if n is between start and up to but not including, end. If end is not specified it's set to start with start then set to 0. If start is greater than end the params are swapped to support negative ranges.

Arguments

  1. number (number)

    The number to check.

  2. [start=0] (number)

    The start of the range.

  3. end (number)

    The end of the range.

Returns (boolean)

Returns true if number is in the range, else false.

Example

_.inRange(3, 2, 4);
// => true

_.inRange(4, 8);
// => true

_.inRange(4, 2);
// => false

_.inRange(2, 2);
// => false

_.inRange(1.2, 2);
// => true

_.inRange(5.2, 4);
// => false

_.inRange(-3, -2, -6);
// => true