Maybe it's Friday morning and I'm having a moment but cant see why this isn't working.
I have this JSON
var recipes = [{
name: "Beef Lasagne",
ingredients: [
"mince",
"pasta",
"sauce",
"tomatoes"
]}]
I can do this: recipes.filter(recipe => recipe.name.includes('e')) and it filters correctly
however when I try and do this: recipes.filter(recipe => recipe.ingredients.includes('e'))
I get I'm trying to filter a string in ex1 and then in ex2 im filter an array, what else do I need to do to get the filter in the second one working?
recipe.ingredients.includes('e')- you need to add a filter to that array too or add an ingredient that is just "e"String.includes()will look for a specific string inside another string.Array.includes()will look for the exact element. Sorecipe.ingredients.includes('e')only works if the string'e'is part of the ingredients. Are you trying to search if any of the ingredients has the letter 'e' in it?