#5: What is wrong with my code?

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-javascript/lessons/variables/exercises/string-interpolation?action=lesson_resume

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
The code works without the + operator but not with it.

Errors are:
Expected an identifier and instead saw ‘)’
Expected ‘)’ but instead saw ‘;’
Missing semicolon



var favoriteAnimal = 'cat';
console.log('My favorite animal:' + favoriteAnimal +);


You mean the last “+” added makes it go though

This should run pass.

console.log('My favorite animal:' + favoriteAnimal);

Oh, now I get it! In the example there was a “+” before and after the variable but I guess the last one is unnecessary if the variable isn’t followed but another string. Thanks!

Yup. The “+” concatenates.

You’re welcome.

Have fun coding! :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.