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 Complete the Loop

Seth Johnson
Seth Johnson
2,676 Points

Isn't this just missing the condition "counter > 11" ? I can't figure out what else would be missing.

If the counter starts at 1, then to run it 10 times you would just need the condition "counter > 11" in the parentheses. When I add this condition, I get an error message saying that document.write() is run undefined times.

script.js
var counter = 1;
while ( ) {
    document.write("<p>Now in loop #" + counter + "</p>");
    counter += 1;
}

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Seth,

You're on the right track, you're just using the 'greater than' comparison instead of less than. Fix that and you are good to go

while ( counter < 11 )

Keep Coding! :)