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 trialKristian Woods
23,414 PointsWhy don't you add a semicolon for the i variable counter at the end?
I noticed that at the end of the for loop that you don't include a semicolon for the "i" counter variable. However, you add a semicolon after each one that comes before.... why?
for (var i = 0; i < 10; i+=) {
*code*;
}
Jacob Mishkin
23,118 Pointsedited code for formatting.
3 Answers
Jacob Mishkin
23,118 PointsIt's redundant. The () represent the beginning and end of the code statement. A semicolon is used to separate each expression. the last expression doesn't need a semicolon because there is nothing else in the statement.
Kristian Woods
23,414 PointsThanks, bud
Jacob Mishkin
23,118 Pointsyeah man, any time.
Kristian Woods
23,414 PointsSorry, I wasn't clear on that. I'm referring to JavaScript for loops.
reza sajadian
718 PointsSo, I mean, are we on the same boat? , or something is going wrong? because I haven't had any relation with java! :)
reza sajadian
718 Pointsreza sajadian
718 PointsSorry, are you talking about my code in Python?