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 trialEmmanuel Darmon
6,115 Pointsindex++
I didn't really get why "index++" stops the loop ? What does this index++ exactely mean ?
1 Answer
Steve Hunter
57,712 PointsHi there,
The ++
operator increments the variable. So if index
is set to zero, index++
will increment it by one to 1.
For a while
loop, does the loop have a condition attached to it? Like while index is less than 10, keep repeating the code. In that instance, index++
will halt the execution of the loop as soon as it has run enough times to make index
equal to 10.
I hope that makes sense.
Steve.
Emmanuel Darmon
6,115 PointsEmmanuel Darmon
6,115 PointsMakes sense! Thanks a lot :)
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsNo problem! :-)