LC 101, Ch. 9 Studio Part A

Hi guys, quick question on the Ch. 9 Studio Part A.
Does anyone know if it’s possible to evaluate multiple arrays in one For Loop?

For example, is it possible to write one For Loop that evaluates all 5 of the arrays in one go (protein, grain, etc.) OR do we have to write 5 For Loops - one for each of the arrays (one for for protein, one for grain, etc.)?

I went back to the notes and also did a Google search for “can a for loop evaluate multiple arrays javascript” but so far I only see examples of a For Loop evaluating one array at a time? That seems like overkill so I’m thinking this must be wrong!

If they are the same length you should be able to I believe. You just don’t want some undefined special value showing up.
I did this exercise with a nested for loop but I might have complicated it. If you figure it out with 1 please let me know.

Cool will do @StephNau - going to give it another try this week

1 Like