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

SHUTO KAKU
SHUTO KAKU
15,001 Points

Can anyone help me this challenge.. i didn't understand why i was wrong.

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

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

2 Answers

M Khan
M Khan
7,024 Points

put less than sign < instead of greater than sign. And also what is "var" keyword doing at line 5. Try this:

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

} 
Shay Paustovsky
Shay Paustovsky
969 Points

Hi There,

In your code the operator is incorrect, it should be { < } and not { > }. Because you initialize the variable as '1' and it is never greater than '10' the loop never runs.

Hopefully this helped

Shay