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

Did anyone understand the second challenge question? I could not understand what to write for var msg

I was able to understand how to put my firstName in and lastName in but did not get what string to use under "let role".

app.js
let firstName = 'Alana';
let lastName = 'Warson';
let role = 'developer';
let msg = firstName + ' ' lastName + ' ' role + '.';

2 Answers

Cameron Childres
Cameron Childres
11,817 Points

Hi Alana,

You're almost there. You've got the right idea combining the variables in to a string and storing it in msg, the issue is with your punctuation of the created string and that you're missing plus signs after the spaces -- a plus sign is necessary between every string that is being concatenated.

The challenge asks to make a string matching the format of "Carlos Salgado: developer", or in your case "Alana Warson: developer". Note the colon after the last name and that there isn't a period inside the string.

Your code with plus signs added where necessary:

let msg = firstName + ' ' + lastName + ' ' + role + '.';
// produces "Alana Warson developer.", does not match

And with punctuation corrected:

let msg = firstName + ' ' + lastName + ': ' + role;
// produces "Alana Warson: developer", exact match

Hope this helps, let me know if you have any questions :)

Thank you for your help. But how would you put this string into using template literal

Cameron Childres
Cameron Childres
11,817 Points

To format it as template literal you'll just wrap it in backticks and use string interpolation for the variables. I find a template literal much preferable here because you don't have to keep concatenating strings together:

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