I am still relatively new to JS, so can someone please explain how the “in” operator functions? I understood that it searches for an index (when given a number) or a string in an object and an array and returns a true/false statement accordingly.
Can someone explain how the “in” operator is working here in the below code? This is a recipe app and the “in” operator is being used to display the list of ingredients as shown, all the data taken from an API.
Screenshot of JS file:
From what I understand the variable “i” is entering the object and starts searching for the string “strIngredient” using the startsWith( ) function.
Then what is the condition : myMeal[i] doing ?? Is it ensuring that the “in” operator doesn’t go further into the other API objects?