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 Review while loops, do...while loops, and Loop Conditions

help with question

It's telling me to put 10, and I did and pop up as an error

1 Answer

andren
andren
28,558 Points

Are you referring to the question that includes this code:

var x = 0;
do {
  console.log('I love JavaScript');
  x += 1; 
} while ( x <= _ )

If so then it's not asking you to enter the number 10, it's asking you to enter a number that would make the loop run 10 times. If the condition is x <= 10 then the loop would actually run 11 times, because the loop starts with x at 0, not at 1.

As such you the condition needs to be x <= 9 in order to loop 10 times.