const newShape = [
{
category: "Groceries",
options: [
...all the objects from the input array with the category "Groceries",
{
name: "Eggs",
value: 'eggs'
}
]
},
{
category: "Tools",
options: [
...all the objects from the input array with the category "Fools",
{
name: "Screwdriver",
value: "screwdriver"
}
]
},
...etc for each unique category value
]
const newShape = [
{
category: "Groceries",
options: [
...all the objects from the input array with the category "Groceries",
{
name: "Eggs",
value: 'eggs'
}
]
},
{
category: "Tools",
options: [
...all the objects from the input array with the category "Fools",
{
name: "Screwdriver",
value: "screwdriver"
}
]
},
...etc for each unique category value
]