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 trialDaniel Williams
Courses Plus Student 1,325 PointsAfter several attempts still having trouble solving this do while quiz
tried to solve this quiz. Somehow I keep getting it wrong.
1 Answer
Krishna Pratap Chouhan
15,203 PointsThere are three things in the code that are relevant: loop; print-variable; increment-value.
loop is do-while;
print-variable & increment-value: what Steven explained above.
So, as an example... with do-while loop, try printing...
1
2
3
4
If you can print that, then just increase the increment-value. Above its 1, and the question demands 2.
I have added exact answer, you can try first before checking that out.
.
.
.
.
.
Answer...
#1
#3
#5
#7
#9
#11
#13
#15
var x = 1;
do {
console.log('#' + x);
x += 2;
} while ( x <= 15 )
Daniel Williams
Courses Plus Student 1,325 PointsDaniel Williams
Courses Plus Student 1,325 PointsFinish 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 )