If I have an object like this (or similar):
sales = {
obs1:{
Sales1:{
Region:North, Value: 200},
Sales2:{
Region:South, Value:100}},
obs2:{
Sales1:{
Region:North, Value: 50},
Sales2:{
Region:South, Value:20}
}
}
How could I aggregate the sum of the property Value
by Region
? Answers could be in pure JavaScript or a library.
The end result should be something similar to this:
totals = {North: 250, South:120}