Function mean

  • Find the mean of an array.

    Type Parameters

    • T

    Parameters

    • array: T[]

      An array.

    • Optional iteratee: ((obj) => number)

      The iteratee invoked on each element.

        • (obj): number
        • Parameters

          • obj: T

          Returns number

    Returns number

    Returns the mean.

    Since

    0.1.0

    Example

    mean([1, 2, 3])
    // => 2

    const objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]
    mean(objects, ({ n }) => n)
    // => 5