Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Basic and Multiple Line Strings

What if I wanted to put another variable between the backticks that contained a string, would I have no choice but to...

use a + to insert the variable?

Joel Kraft
Joel Kraft
Treehouse Guest Teacher

Hi nathanielcusano,

Did Osama answer your question? Or do you still need help? If you still have questions, please provide a bit of code demonstrating your question, and I will try to help clarify.

Thanks, Joel

thanks Osama answered it

Joel Kraft
Joel Kraft
Treehouse Guest Teacher

Great! I changed his comment to an answer and marked it as accepted. Thanks!

2 Answers

you can do for Example: My name is ${your variable name} and i'm from ${your variable name}

Tom Geraghty
Tom Geraghty
24,162 Points

The answer wasn't explicit, but the MDN makes it clear that the syntax Osama used is required (including the dollar sign and curly braces).

From the MDN on Template Literals

`string text`

`string text line 1
 string text line 2`

`string text ${expression} string text`

tag `string text ${expression} string text`

And

Template literals can contain place holders. These are indicated by the Dollar sign and curly braces (${expression}).