Here is the data I have:
companyList: [
{
company_name: 'company1',
item: 'item1'
},
{
company_name: 'company1',
item: 'item2'
},
{
company_name: 'company1',
item: 'item3'
},
{
company_name: 'company2',
item: 'item4'
}
]
This is the desired output format:
result: [
{
company_name: 'company1',
product: [
{ item: 'item1'},
{ item: 'item2'},
{ item: 'item3'}
]
},
{
company_name: 'company2',
product: [
{ item: 'item4'}
]
}
]
How can I achieve this output using map
?