Function randomInt

  • Category

    Generate a random integer within the given bounds.

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • min: number

      Lower bound (inclusive) of the output range

    • max: number

      Upper bound (exclusive) of the output range

    Returns number

    A random integer within the given bounds

    Math

    Example

    randomInt(0, 3); // 0, 1, or 2