I have an array in JavaScript that looks like this:
[
{ quantity: 1, name: 'Menu sandwiches' },
{ quantity: 1, name: 'Menu sandwiches' },
{ quantity: 1, name: 'Menu sandwiches' },
{ quantity: 1, name: 'Pizza' },
{ quantity: 1, name: 'Piza' }
]
Now, I want to transform this array into:
[
{ quantity: 3, name: 'Menu Sandwich' },
{ quantity: 2, name: 'Pizza' }
]
Can someone please help me achieve this?