Here is a representation of my array, which is not a type of string but its own object called MyObject (similar to setter and getter objects in Java)
["Car","model","year","color","price"]
["Table","model","year","color","price"]
["Car","model","year","color","price"]
["Car","model","year","color","price"]
["Laptop","model","year","color","price"]
["Laptop","model","year","color","price"]
I am looking to group this data in TypeScript and count the occurrences of each item in the array (similar to how it's done in SQL)
name |count
Car | 3
Laptop| 2
Table | 1
In my TypeScript file, I have the following code:
private groupByObjects() {
//this reads all data in the 'allData[]' array from the service
this.dataService.retrieveData().subscribe(allData => {
});
}
Can anyone assist me in writing this logic in TypeScript?