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

Megan Cross
Megan Cross
2,045 Points

I have tried this three different ways and it won't pass what's wrong

complete the loop

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

1 Answer

Steven Parker
Steven Parker
231,248 Points

You're on the right track, but "<= 10" is not a complete comparison. You still need a term on the left side to compare with.

It looks like the code is set up to initialize and increment a variable named "counter" that might be useful.

Steven Parker
Steven Parker
231,248 Points

What I was suggesting:

while ( <= 10) {         // instead of this
while (counter <= 10) {  // perhaps you'd want this