Hey everyone, I've been working on a system where I'm adding products to a cart and saving the selected items in sessionStorage. Here is the JSON data structure that I have saved:
[
{
"product": {
"ref": "42101",
"price": 390,
"image": "https://via.placeholder.com/200x200"
},
"combinations": [
{
"type": "REVAS",
"option": "REVVNL"
},
{
"type": "CORAS",
"option": "VNL132"
},
{
"type": "APCAB",
"option": "VNL132"
}
],
"amount": 1
},
{
"product": {
"ref": "42101",
"price": 390,
"image": "https://via.placeholder.com/200x200"
},
"combinations": [
{
"type": "REVAS",
"option": "REVVNL"
},
{
"type": "CORAS",
"option": "VNL132"
},
{
"type": "APCAB",
"option": "VNL132"
}
],
"amount": 5
}
]
Everything in this JSON data remains constant except for the 'amount' key, which varies. Is there a way to check if the objects are identical and then sum up the 'amount' values?