I have an array of objects in TypeScript which have the same key and I want to group them in a row, for eg.:
[{key: 'test', field1: 'abc', field2: 'xyz', price: 10.5},
{key: 'test', field1: 'abc', field2: 'xyz', price: 1},
{key: 'test', field1: 'abc', field2: 'xyz', price: 20.5},
{key: 'test2', field1: 'r', field2: 'q', price: 20},
{key: 'test2', field1: 'r', field2: 'q', price: 50}]
The result should be as follows:
[{key: 'test', field1: 'abc', field2: 'xyz', price: 32},
{key: 'test2', field1: 'r', field2: 'q', price: 70}]
Can you please help me to achieve this since I'm new to typescript?