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
Jong Kim
6,145 Pointswhy are we doing '+= ' sign after message? I know it is ' message += "..." ' is same as ' message = message + "...." '
why are we doing '+= ' sign after message? I know it is ' message += "..." ' is same as ' message = message + "...." '. If that's right, shouldn't be shown the message variable next to equation? Why don't we just use 'message = "...." ' instead ' message += "...." ' ?
1 Answer
Lee Vaughn
Treehouse TeacherThe difference is that you want to add to what was previously already a part of the message variable.
"Message =" would only be equal to what follows. It would override anything that was previously associated with the Message variable.
"Message +=" is equal to what was previously a part of the Message variable PLUS whatever follows.
Jong Kim
6,145 PointsJong Kim
6,145 PointsThank you :)