I get an array of objects:
const inputStructure = [
{
state: 'LA',
insurance: 'Test1'
},
{
state: 'LA',
insurance: 'Test2'
},
{
state: 'TX',
insurance: 'Test3'
}
]
How can I group objects with the same state
property?
I need to create a function which would return the following result:
const outputStructure = {
'LA': {
state: 'LA',
insurances: ['Test1', 'Test2']
},
'TX': {
state: 'TX',
insurances: ['Test3']
}
}