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

JavaScript The Solution

Mihail Mitrevski
seal-mask
.a{fill-rule:evenodd;}techdegree
Mihail Mitrevski
Full Stack JavaScript Techdegree Student 8,430 Points

Does anyone else have problem with " +=" sign? ..it's not working and i have to deal with the same variable twice .

For example i can't use "message += " ..it is not something i should be worried but it makes me nervous.

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hi Mihail,

I'm not sure I'm understanding your problem? The += operator assigns an additional value to an already existing variable. For example:

let phrase = "Treehouse helps "
phrase += "students learn "
phrase += "how to code."

// Output will be
"Treehouse helps students learn how to code."

This operator does not overwrite what is already in there, but rather adds to the existing content. But in order for the operator to be able to do what it is intended to, the variable being modified has to be in-scope when the += operator is in use. Scope goes beyond the context of this posting, so I won't go into it in detail.

If this doesn't help, you will need to be more detailed in your inquiry. Please provide an example of what you are trying to accomplish, the code you are using (when posting code, please use Markdown or the code will not be readable in the Forum. There is a Markdown Cheatsheet link above the Post button). Also, include any errors your are receiving.

Hope we can help! :) :dizzy: