top_products: [
{
"name": "Unknown New Perfume",
"total_quantity": 8,
"total_sales": {
"cents": 160000,
"currency_iso": "MYR"
}
},
{
"name": "product2",
"total_quantity": 5,
"total_sales": {
"cents": 11500,
"currency_iso": "MYR"
}
},
{
"name": "Lolo perfume",
"total_quantity": 4,
"total_sales": {
"cents": 3600,
"currency_iso": "MYR"
}
},
{
"name": "product1",
"total_quantity": 3,
"total_sales": {
"cents": 3600,
"currency_iso": "MYR"
}
}
]
I have this array which has 4 objects. I am trying to get the element where the total_sales.cents
value has the same value.
How to loop through every element and check which element in total_sales.cents
has the same value?