Returns the sum of a numeric key across all items. Items where the key value is not a number are skipped.
The array to sum.
The numeric key to sum by.
sumBy([{ price: 10 }, { price: 20 }, { price: 30 }], "price") // => 60sumBy([], "price") // => 0 Copy
sumBy([{ price: 10 }, { price: 20 }, { price: 30 }], "price") // => 60sumBy([], "price") // => 0
Returns the sum of a numeric key across all items. Items where the key value is not a number are skipped.