Nav

sumBy

sumBy(Array<T>, (T) → Number): Number

Adds the values returned by the right hand side function

Transform

        
     
1
2
3
4
5
%dw 2.0
output application/json
---
sumBy([ { a: 1 }, { a: 2 }, { a: 3 } ], (item) -> item.a)
// same as [ { a: 1 }, { a: 2 }, { a: 3 } ] sumBy $.a
Output

        
     
1
6