I have a react component with a state that looks like this:
this.state = {
categoryGroups: [
{
groupName: 'Immediate Obligations',
budgeted: '5,000.00',
activity: '3,275.76',
subcategories: [
{
category: 'food',
budgeted: '500.00',
activity: '300.76'
},
{
category: 'rent',
budgeted: '1,000.00',
activity: '1,000.00'
}
]
},
{
groupName: 'True Expenses',
budgeted: '2,000.00',
activity: '1,000.33',
subcategories: [
{
category: 'Car Insurance',
budgeted: '60.00',
activity: '60.00'
},
{
category: 'Gas',
budgeted: '100.00',
activity: '34.50'
}
]
}
]
}
I want to find the total budgeted amount for all of the subcategories in each category group. How can I do this?