I have an array of objects that looks like this below
{
results: [
{
provider: 'google',
title: 'google-title1',
image: 'google-image1'
},
{
provider: 'google',
title: 'google-title2',
image: 'google-image2'
},
{
provider: 'facebook',
title: 'facebook-title',
image: 'facebook-image'
}
]
}
How to convert to looks like in the below format ??? Is it possible ??
{
results: [
{
google :[
{
title: 'google-title1',
image: 'google-image1'
},
{
title: 'google-title2',
image: 'google-image2'
}],
facebook:[
{
title: 'facebook-title',
image: 'facebook-image'
}
]
}
]
}
Question: is there any javascript functionality to achieve this?
I've tried googling this, the problem is that I'm not sure what to Google for (I'm a javascript newbie). Any help is appreciated. thank you