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

quiz question

Finish this code to create a do...while loop.

var counter = 0

_____(console.log(counter); counter += 1; ) ____ (counter < 10 );

I have reviewed the video, several times, but I don't know how to complete this question.

3 Answers

Here you go:

var counter = 0;

do {
  console.log(counter);
  counter += 1;
} while (counter < 10);

Thank you. The answer was simpler than I thought.

Yes, I know the feeling. Been there!

Cindy Lea
PLUS
Cindy Lea
Courses Plus Student 6,497 Points

Have you tried putting in Do in first blank & while in 2nd blank? The first condition happens only if true so its a Do & the 2nd blank is a while & will loop as long as counter < 10.