My question is why does my code (which uses ingredientList[ingredientToSearchFor] !== undefined
) isn’t accepted (the answer is ingredientList.indexOf(ingredientToSearchFor) > - 1
). Don’t these mean the same thing?
Is ingredientList
an object or an array?
ingredientList[ingredientToSearchFor]
will look for a property in an object.
1 Like