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

Below role, create a new variable named msg that combines the firstName, lastName and role variables to create a string

keep receiving bummer. Please help

app.js
let firstName = ("First Name");
let lastName = ("Last Name");
let role = 'developer';
'const msg = firstName + 'Carlos' + lastName + 'Salgado' + developer;

1 Answer

Cameron Childres
Cameron Childres
11,818 Points

Hi Savannah~

The challenge wants you to build the variable msg out of the other variables that you've already declared. It's also asking that it looks similar to "Carlos Saldago: developer"

You can do that by concatenating the strings:

let msg = firstName + " " + lastName + ": " + role;

Or by using a template literal:

let msg = `${firstName} ${lastName}: ${role}`;

Notice that in the first example I gave I added in a space between the first two variables in quotes, and then a colon and space between the last two in quotes -- this is because they are not part of the variables we're using. Otherwise the result would look like CarlosSaldagodeveloper. This isn't needed in the template literal since everything inside the backticks is read as it is typed, except for the variables declared within ${}.

Also -- remove the parentheses in your first two variable declarations. They shouldn't be there, the quotes are what determine it is a string. And lastly firstName and lastName are intended to be set as names, not as "First Name" and "Last Name". If you don't want to use your own name just use the one in the example like so:

let firstName = 'Carlos';
let lastName = 'Saldago';
let role = 'developer';