I have an object:
cont obj = [
{id: 1 , value: 4, trash: 'klfjsk'}
{id: 2 , value: 0, trash: 'klf'}
{id: 1 , value: 2, trash: 'jjjsk'}
{id: 2 , value: 7, trash: 'jsk'}
{id: 1 , value: 6, trash: 'aaaak'}
]
What I need as a result is a map wich the K is the id and the V are the sum of their values.
[{1:12}, {2:7}]
My approach is to do a for loop through the object adding each value that corresponds to the first key and then the same for the secon key. The totals would be stores in an array. Then I would make a map and set the obj keys with the array values.