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 get an error message cannot read property "`" of null. What does that mean?

var firstName = "Dorian"; var lastName = "Ellison"; var role = "developer"; var msg = firstName (" ") lastName : role;

app.js
var firstName = "Dorian";
var lastName = "Ellison"; 
var role = "developer";
var msg = firstName (" ") lastName :  role;

My cousin is a developer and gave me this as a solution:

${firstName} ${lastName}: ${role};

The challenge task accepts this as a correct response, however the videos did not cover characters such as "`", "$", or "{}". The videos also don't cover why that would work. Why wasn't it covered? Did I miss something?

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Dorian Ellison! The backticks, dollar signs, and curly braces just haven't been covered yet. But they will be! Your friend's solution was valid assuming it had the backticks. It's called a "template literal" and you will be taking courses/workshops later that cover them. You just aren't there quite yet!

It would be impossible to cover everything all at once, but if you continue down the same path, you will get there :smiley:

You could have also solved this using normal concatenation.

This would have also worked:

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

Your attempt seems to be missing any + signs to perform the concatenation. Also, the colon and accompanying space would need to be enclosed in quotation marks to create a string literal.

Hope this helps! :sparkles:

wow you're right. It's very easy to miss 1 minor detail that makes the difference. Thank you. At first I had ":" + " ", but I see now that you can have the space and the colon within the same literal! Thank you.