Suppose I have a JS array like this:
[
{
"lat": 49.26125,
"lon": -123.24807,
"weight": 120
},
{
"lat": 49.26125,
"lon": -123.24807,
"weight": 80
},
{
"lat": 49.26125,
"lon": -123.24807,
"weight": 160
},
{
"lat": 49.26229,
"lon": 23.24342,
"weight": 236
},
{
"lat": 49.26229,
"lon": 23.24342,
"weight": 167
}
]
Suppose I want to add up the weights the elements that have the same lat & lon to get something like this:
[
{
"lat": 49.26125,
"lon": -123.24807,
"weight": 360
},
{
"lat": 49.26229,
"lon": 23.24342,
"weight": 403
}
]
what's an efficient way to do that in JS?