28. Hello? Yes, This is Dog


What is wrong with my code? The error mesage says: "SyntaxError: missing ) after argument list".
Here is my code


console.log("Hello this is a " this.breed " dog);

This is an incorrect way to insert a variable into a string.


Thanks for your attencion, but, what do you say it is the correct form?


It is called String Concatenation, or putting strings together.

You simply use the Concatenation Operator +.


Haha, I don´t know why I didn´t remember to do that, haha, thanks!


Off topic

Now with the introduction of ES6, JavaScript finally has string formatting (template string) and string interpolation similar to Ruby that takes the place of concatenation.

console.log("Hello this is a ${this.breed} dog");

Don't try it here, though. This site still uses ES5, though the new courseware appears to be going in the direction of ES6.