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 trialSun Min
2,941 Pointsfor loop
Does semi-colon at the end of for loop that make syntax error. why I should not put ; at the end of for loop?
1 Answer
Greg Kaleka
39,021 PointsHi Sun,
I'm not sure where you'd like to put your semicolon, but in Javascript, the first line of a for loop is not a complete statement - it's just the beginning of the structure, so we don't need a semicolon. Semicolons are meant to tell the parser that a code statement is over.
for (i=1; i<=100; i++) {
console.log(i);
}
Hope this helps.
Cheers
-Greg