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 Working with 'for' Loops Review for Loops and Exiting Loops

3 Answers

Heidi Fryzell
seal-mask
MOD
.a{fill-rule:evenodd;}techdegree seal-36
Heidi Fryzell
Front End Web Development Treehouse Moderator 25,178 Points

Hi Jason,

This was a tricky one.

The answer would be 9 if the condition were: i <=9

But since you could not change the comparison operator to include the equals sign you had to use i < 10 in order for the loop to run 10 full times.

Remember that the loop starts counting at zero.

0 - 1st time 1 - 2nd time 2 - 3rd time 3 - 4th time 4 - 5th time 5 - 6th time 6 - 7th time 7 - 8th time 8 - 9th time 9 - 10th time.

If the condition is set to i < 9, it will evaluate to false when i = 9 and it won't run a tenth time.

I hope that makes sense. Happy Coding!

Heidi