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

Morgan Walstrom
Morgan Walstrom
4,683 Points

What is the correct answer?

what did i do wrong?

Morgan Walstrom
Morgan Walstrom
4,683 Points

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; do { console.log('#' + 1); x += 1; } while ( x <= 15 )

4 Answers

You are only adding 1 to x, while the question is expecting x to increase by 2.

Steven Parker
Steven Parker
229,644 Points

If you use a literal in the log statement, it will always log the same thing (in this case every line will have "#1").

Also, you may need a different increment value if you don't want all adjacent numbers. (1,2,3,4,5 ... etc.)

Morgan Walstrom
Morgan Walstrom
4,683 Points

I figured it out! But thanks for the response guys!

Simon walters
PLUS
Simon walters
Courses Plus Student 8,962 Points

Hey Guys

I am stuck on this question also, I have re-watched the videos numerous amount of times and I can't seem to get my head around this particular question, I have answered 4 out of the 5 questions correctly which allows me to move on to the next part of the course. I would still like to know why I wasn't getting this question, can someone please share with me how they approached this?

Thanks

Simon

Steven Parker
Steven Parker
229,644 Points

Since this question has already been answered, start a new one and show your code in it. If you use the "get help" button in the challenge, it should include and format your code for you.