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 trialRich Braymiller
7,119 PointsI just can't wrap my head around it
I am having a hard time wrapping my head around the += Struggling to understand the shorthand...sorry, I'm new to javascript...
3 Answers
Ayoub AIT IKEN
12,314 Pointsso you have :
i = i + 1;
instead of writing it like that you juste take off the "i" after the equal sign, and you put the addition sign before the equal sign :
i += 1;
it means that you are adding 1 to the last value of "i".
Yaroslav Kleshchev
8,744 PointsLets say you have
var x = 10
Then you do this:
x+= 5
This is saying take x which is 10 , and add 5 to it.
So, x+=5 will give you 15.
Rich Braymiller
7,119 PointsThank you
Ayoub AIT IKEN
12,314 Pointsyou welcome :)