Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Chal Task 2 of 3 create a new variable named msg that combines the first,and lastName and role variables to create strin
let firstName = "Michael"; let lastName = "Jordan"; let role = 'developer'; const firstname = ("Carlos"); const lastname = ("Salgado:"); const message = + "firstname" + "lastname" + ".developer.";
Jason Larson7,955 Points
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'.
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;