Function inRange

  • Determines if a value lies within a specified range (inclusive of the range boundaries).

    Parameters

    • value: number

      The value to check.

    • Optionalmin: number = 0

      The minimum boundary of the range.

    • Optionalmax: number = 1

      The maximum boundary of the range.

    Returns boolean

    • true if the value is within the range (inclusive), otherwise false.
    inScope(0, 0, 1);
    // => true (0 is within the range [0, 1])

    inScope(1, 0, 1);
    // => true (1 is within the range [0, 1])

    inScope(2, 0, 1);
    // => false (2 is outside the range [0, 1])

    inScope(-1, 0, 1);
    // => false (-1 is outside the range [0, 1])