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 Simplify Repetitive Tasks with Loops Review while loops, do...while loops, and Loop Conditions

quiz

3 of 5

1 Answer

Vittorio Somaschini
Vittorio Somaschini
33,371 Points

Hello Caitlen.

In this case you have to spot the endless loop, which means a loop that runs forever. In my case, this was answer letter C, but I am pretty sure they don't always come up in the same order.

What you need to look for is the condition inside the for loop. Which case shows a condition that ALWAYS happens?

If you look closely to the codes, there is one that starts with counter equal to 0 and the condition is counter >= 0. Also the code makes the counter +1 every time the loop runs, resulting in the condition ALWAYS been respected.

That is the endless loop.

I hope it is clear enough.

Vitto