Sandra AlSaigFront End Web Development Techdegree Student 8,548 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 */