Basic usage

Given an array of items, and an optional function to map each item to a number, add up all the items.

import { sum } from 'radash'

const fish = [{
  name: 'Marlin',
  weight: 100
}, {
  name: 'Bass',
  weight: 10
}, {
  name: 'Trout',
  weight: 15
}]

const totalWeight = sum(fish, f => f.weight) // => 125

Testing

This _.sum function is 100% covered by tests. See them and contribute at GitHub.

Source

See the source for _.sum on GitHub.