• Category

    Get the largest value of the 2 parameters. Meant to be used with Array.prototype.reduce.

    Time complexity: O(1)

    Space complexity: O(1)

    Type Parameters

    Parameters

    • accumulator: A
    • currentValue: B

      The next value to compare

    Returns A | B

    previousValue or currentValue, whichever is larger

    Reducers

    Example

    const array = [1, 2, 3];

    array.reduce(max); // 3