variable array has multiple objects so i want to merge objects based on repeated id and other values will assign into offer objects how to do that ?.. Thanks in advance
var array = [
{
id:1,
shopname:'star salon',
offid: 12,
offname:'100% discount'
},
{
id:1,
shopname:'star salon',
offid: 16,
offname:'Billing Value discount'
},
{
id:3,
shopname:'trend beauty',
offid: 19,
offname:'Percentage Offer'
}
]
And finally out put is given below:
var result = [
{
id:1,
shopname:'star salon',
offer : [
{
offid: 12,
offname:'100% discount'
},
{
offid: 16,
offname:'Billing Value discount'
}
]
},
{
id:3,
shopname:'trend beauty',
offer : [
{
offid: 19,
offname:'Percentage Offer'
}
]
}
]