I have the below array
[
{item_id:1,quantity:5},
{item_id:1,quantity:10},
{item_id:2,quantity:45},
{item_id:2,quantity:30},
{item_id:2,quantity:20}
{item_id:3,quantity:10},
]
Now i want to get the sum of each item_id so the result will be the below array
[
{item_id:1,quantity:15},
{item_id:2,quantity:95},
{item_id:3,quantity:10},
]
Could you please help me with this.
Thanks.
.map()or.reduce()function works for Arrays in JavaScript?