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 Loops

CHARLES REROMA
CHARLES REROMA
771 Points

Question about the quiz

Code needs to run 10 times, so I put 9. Counting from 0 to 9, thats ten times I dont know why its wrong.

var counter = 0; while ( counter < 9 ) { console.log(counter); counter += 1; }

1 Answer

andren
andren
28,558 Points

Because if your condition is "counter less than 9" then it will stop as soon as it gets to 8. As 9 is not in fact less than 9.

If you used >= (less than or equal to) then 9 would have worked. The correct answer for this quiz is 10.