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

Vincent C
1,376 PointsIs i++ the same as +=1 in javascript ?
I am looking at loops, and I am wondering if these two codes are the same, but the second option uis just a faster way to type? Thanks
for (i = 0; i < 5; i += 1) { text += "The number is " + i ; }
VS
for (i = 0; i < 5; i++) { text += "The number is " + i ; }
1 Answer

Edward Ries
7,388 PointsActually in this case yes and in a for statement I recommend you use i++ unless you need to step by a higher number. Say if you needed to loop through a list by 2's then you can use +=2.
You might always want to experiment with ++i which.
Kristian Woods
23,414 PointsKristian Woods
23,414 PointsHope this helped