What I am going to do is to get target value from source_value.
var source_value = [
{
"id": 111,
"qty": 2,
"price": 50
},
{
"id": 222,
"qty": 5,
"price": 70
},
{
"id": 111,
"qty": 8,
"price": 50
},
];
var target_value = [
{
"id": 111,
"qty": 10,
"price": 50
},
{
"id": 222,
"qty": 5,
"price": 70
},
]
So in the source_value, there were 2 objects with same id value, and they were merged into one object and qty was added (2+8=10).
How can we do this in javascript?