Grouping array of objects and do a calculation and create a new common value : HI I'm using lodash to group my objects in my array.

`var grouped = _.groupBy(this.tableData, function(obj) {
                return obj.key
            });`


it giving me an object with key value pairs.

`{mykey1: [{obj1}, {obj2}], mykey2: [obj1]}`

My question is how can i loop through the objects inside each key and do a calculation. for example if i have an attribute in my object, cost, i want to sum up all the cost inside each object in my key? Wasted my 2 days for this. can please someone tell me a solution? Thanks in advance