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 trialGabrielle Coleman
1,229 Pointswhy is it counter += 1 and not counter += +1
why is it counter += 1 and not counter += +1
2 Answers
Jennifer Nordell
Treehouse TeacherHi there! You could do that but generally speaking, we donΒ΄t say "add positive one" to a number, we generally just say "add 1". The line you are referring to counter += 1
is shorthand for counter = counter + 1
.
Hope this helps!
Gabrielle Coleman
1,229 PointsYes! Thank you. I didn't realize it was already adding the 1.
jamesjones21
9,260 Pointsif it is for incremental purposes we can do it like var i++; :)
Gabrielle Coleman
1,229 PointsThank you!
Gabrielle Coleman
1,229 PointsGabrielle Coleman
1,229 PointsI have another unrelated question. I am on the beginner JavaScript track. I want to study in more than one track at the same time, so if I hit that 'switch' button will I be able to resume the first track whenever I want and switch back and forth? If I switch tracks will I lose the progress I made in the first track?