So this is how my data looks:
categories = [
{
name: ""
products: [
{
id: 1,
...
},
{
id: 2,
...
}
]
},
{
name: ""
products: [
{
id: 3,
...
},
{
id: 4,
...
}
]
},
...
]
I want to remove a product with id 1 and this is my code:
categories.map(category => category.products.filter(product => product.id !== 1))
Is this the right code? If so how I create a new array and set it with the new values?