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

Kendall Chung
Kendall Chung
9,511 Points

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

Kendall Chung
Kendall Chung
9,511 Points

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;
}
Aaron HARPT
Aaron HARPT
19,845 Points

Here is the correct code inside the while loop:

while(counter < 11)

Aaron HARPT
Aaron HARPT
19,845 Points

Can you post your code?

Kendall Chung
Kendall Chung
9,511 Points
var counter = 1;
while (1<11) {
    document.write("<p>Now in loop #" + counter + "</p>");
    counter += 1;
}
Jesus Mendoza
Jesus Mendoza
23,289 Points

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