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

For some reason the task won't recognize that I am putting a space between my first and last name.

I have the msg variable typed out as

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

am I missing something? ty!

app.js
let firstName;
let lastName;
let role = 'developer';

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

firstName = "Paul";
lastName = "Narrea";

2 Answers

Hey Paul Narrea,

You have assigned a value for the firstName and lastName variable at the very end. JS is a single-threaded language which means it reads code from top to bottom so when JS reads the above code it will execute the following output: undefined undefined: developer

You could change your code into this:

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

firstName = "Paul";
lastName = "Narrea";

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

Or you could just simply write it this way to avoid error

let firstName = "Paul";
let lastName = "Narrea";
let role = 'developer';

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

Hope this helps!

Ah yes that makes a lot more sense now

Didn't take into account the order of things. Great! Thank you so much for your help!

Cheers