I have a scenario where I need to update tire quantities in an array like this:
tires: [{
name: "fancyProduct1",
quantity: 1
}, {
name: "fancyProduct1",
quantity: 1
}, {
name: "fancyProduct1",
quantity: 1
}, {
name: "fancyProduct2",
quantity: 1
}];
My goal is to achieve the following structure:
tires: [{
name: "fancyProduct1",
quantity: 3
}, {
name: "fancyProduct2",
quantity: 1
}]
Does anyone have any suggestions on the best approach to tackle this?