Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics Working with Strings Combine and Manipulate Strings

Chal Task 2 of 3 create a new variable named msg that combines the first,and lastName and role variables to create strin

app.js
let firstName = "Michael";
let lastName = "Jordan";
let role = 'developer';
const firstname = ("Carlos");
const lastname = ("Salgado:");
const message = + "firstname" + "lastname" + ".developer.";

2 Answers

There are so many things wrong here, it's hard to know where to begin.

First, the 2nd task builds on the first, so you don't need to create new variables, except for 'msg'.

Second, the task asks you to create a variable called 'msg', not 'message'.

Third, msg is going to combine the strings you assigned to variables along with additional strings that you're going to add in to make the output look the way they want.

Fourth, when you're using string variables, you don't put the quotes around them. When you put the quotes around them, it turns them into the strings that are within the quotes, rather than what you have assigned to the variables.

let firstName = "Michael";

let msg = firstName;
//msg is now equal to "Michael"

let msg = "firstName";
//msg is now equal to "firstName"

Fifth, make sure when you correct the code by removing your const statements, that you update the variable names in the last line to have the proper case (with the 'n' capitalized in firstName and LastName).

Sixth, I'm not sure what you're doing with the periods around developer, but that shouldn't be developer, it should be role, and again, no quotes (and no periods).

Seventh, you have a plus sign ( + ) after your equal sign when assigning to message. The plus sign is for combining strings (or adding numbers), but you don't have anything before the plus sign, so there's no purpose for that first one.

Finally, for the assignment to 'msg', just add the strings together with plus signs. Use the variable names instead of strings, and add strings in for whatever might be missing from your variables in order to make it look like what they are asking for. For example, if they had asked msg to be assigned lastName, firstName, it would look like this:

let msg = lastName + ", " + firstName;

Thanks Jason.