Function sumByFn

  • It will iterate through each element of the provided values array, by the provided iteratee function and add the resulting numbers returned by the said iteratee function to produce the desired sum.

    Type Parameters

    • Value

    Parameters

    • values: Value[]
    • iteratee: ((value) => number)
        • (value): number
        • Parameters

          Returns number

    Returns number

    Since

    1.0.0

    Example

    sumByFn([1, 2, 3], number => number);
    // => 6

    Example

    sumByFn([{ a: 1 }, { a: 2 }, { a: 3 }], ({ a }) => a);
    // => 6