Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops Review Loops

Help Please

I can't figure this one out.Can someone help me? I dont know what goes into the blank.

var counter = 0; while ( counter < blank ) { console.log(counter); counter += 1; }

2 Answers

Heidi Fryzell
seal-mask
MOD
.a{fill-rule:evenodd;}techdegree seal-36
Heidi Fryzell
Front End Web Development Treehouse Moderator 24,569 Points

The Loop is supposed to run 10 times, so you would put "10" in where it says blank.

Counter starts at zero and and increments +1 every time it goes through the loop.

It keeps running as long as it is less than 10.

Remember the first time the loop runs counter is 0.

So starting at 0 it runs 10 times.

0,1,2,3,4,5,6,7,8,9

Then when it gets to 10 it stops the loop because 10 is > counter.

Thanks,I appreciate u

If it has the requirement: Finish the code below so that the loop runs 10 times

then the blank should be 10. Since the while statement is < blank (not <=), and counter is initialized to 0, the loop will run with counter values 0-9 which would be 10 times.