In the above code, you are using
i correctly (as in you are using it to index into
array). Rather than point you to an article, I think it would be more beneficial to review the lessons on for loops, arrays, and array indices.
All functions must return something. When there is no explicit return statement in the function, the default value of
undefined is returned.
I think what could be very useful is to take a step back and reevaluate what you are trying to accomplish. Let’s look at the big picture. What is the one overall thing you are trying to accomplish with this entire program? Now, take that goal and divide it into smaller, more manageable goals that you can accomplish. Now divide those goals again until you’re left with the simplest goals you need to achieve in order to complete this exercise. What steps do you need to take to achieve those simple goals?
Based on your above code, two questions I think could help guide you toward getting this to work are: 1) How can you figure out whether a certain meal is vegan or not? and 2) Based on the result from question 1, what do you want to do if a certain meal is not vegan?
It’s great that you found an alternate solution using
.every(). I encourage you to solve it using this more naive approach; I believe you’ve just overthought the problem, so try answering the questions I put above and see if that helps. Even if it takes several attempts and posts on the forums, keep working on it until you solve it!