I successfully utilized the lodash module to group my data, demonstrated in the code snippet below:
export class DtoTransactionCategory {
categoryName: String;
totalPrice: number;
}
Using groupBy function:
import { groupBy} from 'lodash';
let result = groupBy(transactionCategoryList, (c: DtoTransactionCategory) => {
return c.categoryName
});
Result:
https://i.stack.imgur.com/KHvST.png
To further manipulate the array and calculate the total price for each category, I need my data to be structured as follows:
let myNewArry = [{categoryName:"cat1",totalPrice: 9400},
{categoryName:"cat2",totalPrice: 600}]
Could you please guide me on achieving this final step using Lodash modules?