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

I am having issues with this question and I don't want to just skip it:

Finish the code in this do/while loop, so that the following lines are output to the console:

1

3

5

7

9

11

13

15

var x = 1; ______________ { console.log('#' + _______); x += _______; } ___________ ( x <= 15 )

I have this so far and would like someone to explain how they got the middle blank lines: var x = 1; do { console.log('#' + ____); x += _______; } while ( x <= 15 )

Are you sure there are blank lines in the middle? I think the concept is just to understand the basic loop structure and that the increment doesn't have to always be a 1.

Pretty sure all you are missing is what value to concat with the "#" and what the increment amount should be (and it isn't 1).

Does that help?

4 Answers

You're off to a good start! You're going to want to log the variable, x, to the console. That's your first remaining blank. Each time you go through the do while loop you want the value of x to increase by 2. So, that's what you'll want to add in the last blank you have left. Hope this makes sense!

var x = 1;
do { 
  console.log('#' + x); 
  x += 2; 
} while ( x <= 15 );

Also it i written w/ "#" before the line numbers

I was overthinking it plus not recognizing that the numbers were every other line. I figured it out. Thank you.

var x = 1; do { console.log('#' + x); x += 2; } while ( x <= 15 )