Tanmay_Sarkar
5 years agoNew Contributor III
Sum of values in array of objects without reduce function
Hello all,
I stumbled upon a situation where I have to find out a sum of a certain key in the objects residing in an array without reducing the objects? What I mean to say is, here is the input:
...
- 5 years ago
You can use merge function too.
Community_Example_2021_05_11.slp (3.5 KB)
$group.map(x=>x.merge({“sum”:$group.map(item => item.key2).reduce((accum, currentValue) => accum + currentValue)}))