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 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 25,178 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.