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

I have tried everything to have spacing between the firstName and lastName but still no luck

app.js
let firstName = "Xolani";
let lastName = "Mdluli";
let role = "developer";
let msg = "firstName " + " " + " lastName"  + "." + "role";

4 Answers

Steven Parker
Steven Parker
231,248 Points

Heidi's right about the colon character, but there should also be a space after it.

However, the main issue here is that variable names should not be enclosed in quotes!

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

First, your code works on my Chrome console (with spaces).

You can also use template literals (``) :

let msg = ${firstName } ${lastName}.${role};

I don't think this came out the way you intended because of the markdown. It's a good idea to preview your answers before posting to ensure they look like what you intended. I think you meant to write:

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

You can also put text in code boxes, which makes it even easier to read:

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

Note that the proper solution should actually be one of these 2 options:

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

let msg = firstName + " " + lastName + ": " + role;
Heidi Fryzell
seal-mask
MOD
.a{fill-rule:evenodd;}techdegree seal-36
Heidi Fryzell
Front End Web Development Treehouse Moderator 25,178 Points

Hi Xolani,

I also think you might be running into trouble because you put a "." before "developer".

The instructions say that they want a ":".

"Carlos Salgado: developer"

Hope this helps and happy coding!

Thank you all for the assistance. I made it past the challenge.