I am needing to build a custom object from an array of objects in Typescript.
In the giving example below, How do I count how many times the salesman_1_name is in the Array, Add the gross for each Salesman_1_name, and count if warranty is not null for each salesman_1_name? So if I have:
[
{salesman_1_name:Brian, gross:100, warranty: Easycare},
{salesman_1_name:Brian, gross:100, warranty: Easycare},
{salesman_1_name:Brian, gross:100, warranty: null},
{salesman_1_name:Kreso, gross:100, warranty: null},
{salesman_1_name:Filip, gross:100, warranty: Easycare}
]
I would need to output:
[
Name:Brian, Count:3, Gross:300, WarrantyCount:2,
Name:Kreso, Count:1, Gross:100, WarrantyCount:0,
Name:Filip, Count:1, Gross:100, WarrantyCount:1
]
Easycarea string? where do you getWarrantyCountfrom?Filip ... WarrantyCount:1andBrian ... WarrantyCount:2?