Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Loops, Arrays and Objects Tracking Data Using Objects The Student Record Search Challenge Solution

Andy tran
Andy tran
7,112 Points

Question about an inner loop nested in an outer loop?

When we have one inner loop nested in the outer loop, is it like the inner loop must exit its loop before the outer loop can run again or both loops (the inner loop and the outer loop) run at the same time?

1 Answer

Alexander Solberg
Alexander Solberg
14,350 Points

When the inner loop has completed, the outer loop continues it's iteration and initiates a sequence of the inner loop yet again. So basically the outer loop waits for the inner loop to finish up before moving on to the next step, then it waits again, and again, until all iterations of the outer loop is complete.