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見綸 陳
6,333 PointsQuestion about " ; " ?
In the for loop, we set i += 1, to make variable i increase 1 each time.
I want to ask why don't we put " ; " after i += 1 Just like this --> for ( var i = 0; i < 10; i +=1; )
1 Answer
Iain Simmons
Treehouse Moderator 32,305 PointsUnfortunately the answer for this is just because that's the syntax for the for loop that the creators of JavaScript decided on.
I guess the one advantage is that is helps to distinguish the loop syntax from a function.
見綸 陳
6,333 Points見綸 陳
6,333 PointsOkay! Thanks a lot~