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

This is a nearly complete while loop, but something is missing. The loop should run 10 times, but it's not working at al

This is a nearly complete while loop, but something is missing. The loop should run 10 times, but it's not working at all. Can you fix it?

Bummer! Your code took too long to run.

hey guys, i am attempting to answer this question. i think my answer is correct but for the last 12 hours i have been getting this response. i think its a sever problem. Can someone please help me out? THANKS!

4 Answers

OH! thanks guys! here is the answer for anyone else whos having trouble :)

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

Here is the correct code inside the while loop:

while(counter < 11)

Can you post your code?

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

Hey Kendall, the thing is that you're adding 1 to your while loop instead your variable counter!