I am working with an array of objects that needs to be sorted by category, and I also need to find the total number of items in each category. In the example provided below, all categories with "toys" should be grouped together for easier counting, like in this case where there are 2 items in the "toys" category.
[
{ "category": "toys", "name": "cycle", "itemID": 1594, "price": 1594},
{ "category": "furniture", "name": "chair", "itemID": 15954, "price": 1594},},
{ "category": "furniture", "name": "table", "itemID": 15344, "price": 1594},},
{ "category": "books", "name": "twoLittle", "itemID": 153594, "price": 1594},},
{ "category": "electronic", "name": "Tape", "itemID": 134594, "price": 1594},},
{ "category": "books", "name": "oneLittle", "itemID": 1594436, "price": 1594},},
{ "category": "electronic", "name": "TV", "itemID": 159446, "price": 1594},
{ "category": "toys", "name": "car", "itemID": 1534694, "price": 1594},
]
Would appreciate any guidance on how to approach this issue.
Thanks a lot for your help.