I have 3 objects with the same data, but inside the array there is a separate service and offer identifier, so I tried to get the expected result, as indicated below, and check my attempt here . thanks in advance
Object 1:
const obj1 = {
bid : 1,
mobile : 9533703390,
services : [
{
service_id : 5,
offer_id : 10,
count : 1
}
]
}
object2:
const obj2 = {
bid : 1,
mobile : 9524703390,
services : [
{
service_id : 8,
offer_id : 12,
count : 1
}
]
}
object 3:
const obj3 = {
bid : 1,
mobile : 9524703390,
services : [
{
service_id : 5,
offer_id : 10,
count : 1
}
]
}
The end result - each object that has separate services and offers then, if the same offerid and serviceid came, you need to add count + 1 otherwise return the data
const result = {
bid : 1,
mobile : 9524703390,
services : [
{
service_id : 5,
offer_id : 10,
count : 2
},
{
service_id : 8,
offer_id : 12,
count : 1
}
]
}