28. Hello? Yes, This is Dog


#1

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


#2

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

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


#3

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


#4

It is called String Concatenation, or putting strings together.

You simply use the Concatenation Operator +.


#5

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


#6

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.