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

Brian Jacobs
Brian Jacobs
4,117 Points

Combine and Manipulate strings test

My error message keeps popping up with spacing errors. Ive searched outside and on this app and cannot seem to get it right . Please help?!?!

app.js
let firstName = 'Brian';
let lastName = 'Jacobs';
let role = 'developer';
let msg = "firstName + ''lastName':'+ role'.' "

1 Answer

Ignacio Rocha
Ignacio Rocha
7,462 Points

if you want to call another variable inside a new variable you need to take off the quote marks for every variable, and look closely that the second task ask for specific values for firstName and lastName.

let firstName = 'Brian';
let lastName = 'Jacobs';
let role = 'developer';
let msg = firstName + ' ' + lastName + ': ' + role 
Austin Whipple
Austin Whipple
29,725 Points

And to expand on Ignacio's answer, the reason this fails with single quotes is because wrapping text in single or double quotes is a way of indicating a string. This challenge is suggesting you pass in the value of a variable. So, for instance, firstName without the quotes will pass through "Brian". However, if you wrap firstName in the quotes, it will output, literally "firstName" as a string.