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 trialChinonso Umeanoikwa
Courses Plus Student 1,359 PointsCombining strings via Concatenation
Below role, create a new variable named msg that combines the firstName, lastName and role variables to create a string like "Carlos Salgado: developer".
- let firstName = 'Carlos';
- let lastName = 'Salgado';
- let role = 'developer';
My answer
- let firstName = "Carlos";
- let lastName = "Salgado”;
- let role = 'developer';
- let msg = 'firstName' + 'lastName’ + 'role’;
I am getting a Bummer. Please help.
1 Answer
Guillermo Gallo
Full Stack JavaScript Techdegree Student 8,518 PointsYou are close, but you need to make some adjustments. Right now you are just saving the string firstNamelastNamerole to the msg variable.
You need to remove the quotes around the variable names in order to get the variable’s value. Or you can use template literals with backticks to create the correct string with the variable names. If using backticks, remember to use interpolation to add the variable values into the string.
Finally you need to make sure you have the format required for the challenge, in this case you are missing some white spaces between first and last name and you are also missing an : and a white space after the last name.
Something like this:
let msg = firstName + “ “ + lastName + “: “ + role;
Or with backticks
let msg = `${firstName} ${lastName}: ${role}`;