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

How do I called it 10times

Where am get wrong the question wat do I have do with documen.write method with loop

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

1 Answer

Hi Abdullahi, In your example your code only runs nine times. You can either use my code below or just set the counter variable to zero.

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

Great very helpful thanks