Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Sandra AlSaigFront End Web Development Techdegree Student 11,501 Points
Question regarding the last 3 lines.
Hi all! So, I had to concatenate the last 2 lines of the code (above the print(message) call) to make sure it looks like Dave's on the browser. (using Chrome)
I know it isn't a big deal, but I feel like I need to know why that is.. 🙃🤓
Thanks in advance for any help..
Have a great day & Happy coding!!! 🌻🙏🏼
👉🏼message += "<p> I have " + person.skills.length + " skills: " + person.skills.join(", ") + "</p>";
Actually he has concatenated the last two strings. On the message variable he has used a += then written the paragraph. The += signs are used frequently in JS for a number of reasons of which one of the reasons is to take a set of strings and put them together.
Check out this link for some detail:
Concatenating means joining up strings. If you dont concatenate the above strings then it would just be treated as separate lines. By adding the strings together, it will treat it as a single complete string. I hope that made sense.
For example, lets suppose I had two variable:
var string1 = "Hello my name is"; var string2 = "furkan"; /* No concatenation and the strings will be treated separately. But I want to concatenate the two so it says "Hello my name is furkan"... So, you can use the plus operator (+) to join the two strings up */