Imagine having an array containing different objects:
[
{ "category": 121, "item": "item1" },
{ "category": 128, "item": "item2" },
{ "category": 130, "item": "item2" },
{ "category": 130, "item": "item2" }
]
Your goal is to filter this array and generate new objects based on the item field.
The desired outcome should look like this:
[
{ "category": 121, "item": "item1" }
]
[
{ "category": 128, "item": "item2" },
{ "category": 130, "item": "item2" },
{ "category": 130, "item": "item2" }
]
In order to achieve this task efficiently, I recommend using typescript and lodash. Although attempts with lodash groupBy and ES6 mapping were made previously, they did not yield successful results. Perhaps a cleaner solution involving smart usage of loop functions could provide an easier way to accomplish this objective.