How to sum object array with the same key value?
I have this array:
let arrData = [{ category: "Main Expenses", amount: 420 },
{ category: "Food", amount: 50 },
{ category: "Main Expenses", amount: 4530},
{ category: "Food", amount: 4520 },
{ category: "Main Expenses", amount: 4530 },
{ category: "Food", amount: 450 },
{ category: "Self Care", amount: 7540 },
{ category: "Child Care", amount: 4570 }]
And I need to get array with unique categories, like this:
[Main Expenses: 9480,
Food: 5020,
Self Care: 7540,
Child Care: 4570]