DEV Community

Discussion on: Javascript: how to merge multiple objects with sum of values

Collapse
 
trongphamitr profile image
trongpham-itr

I use lodash library

const _ = require('lodash');
const fruits = [];
_.reduce(fruits, (prev, curr) => _.mergeWith(prev, curr, _.add))
Enter fullscreen mode Exit fullscreen mode