How do I filter such array:
const recipes = [
{
"id": 1,
"name": "Boiled Egg",
"ingredients": [
"egg",
"water"
],
},
{
"id": 2,
"name": "Pancakes",
"ingredients": [
"egg",
"milk",
"flour"
],
},
{
"id": 3,
"name": "Bread",
"ingredients": [
"flour",
"water",
"salt"
],
},
]
based on elements in such array
const selectedIngredients = ["milk", "salt"]
I played with combination of array.filter, array.some as show in Check if an array contains any element of another array in JavaScript but can't get it working properly
I want to get recipes with id 2 and 3 as a result