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 trialluisgomez7
5,557 PointsHow do I write finish this code? I have no idea.
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 )
2 Answers
tobiastrinkler
Full Stack JavaScript Techdegree Student 16,538 Pointsvar x = 1;
do {
console.log('#' + x);
x += 2;
} while ( x <= 15 )
Hei Luis the variable i is always increasing by two: 1,3,5,7 etc.. Therefore you want to increase the i variable in the loop by two everytime the loop runs :).
luisgomez7
5,557 PointsThanks
Scott James
2,516 PointsScott James
2,516 PointsHow do you know that the variable is always increasing by 2?
Thanks
EDIT: I have just taken proper notice of the numbers above since reading your post!!