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 JavaScript Basics Working with Strings Write a Template Literal

Trevor Terry
Trevor Terry
720 Points

I need help. I feel like Im doing what the statement is asking but it's not right.

I'm not understanding this statement:

Make sure you're including : $ immediately after type and before `price

const flavor = "Blueberry";
const type = "Smoothie";
const price = 4.99;

const drink = `${flavor} + ' ' + ${type} + ':$ ' +  ${price}`;

2 Answers

const drink = ${flavor}${type}: $${price};

^ the answer. you can't concatenate(add) template literals the same way you do strings. Think of it like this the drink costs ${price} would evaluate to "the drink costs 4.99" <- notice how there is no "$"? that's because ${} is the syntax that contains your variable and it is sort of 'ignores' everything around it and only prints what's inside of it. so $${price} would print $4.99. I hope this helps!

The current value of drink is the string "Blueberry + ' ' + Smoothie + ':$ ' + 4.99" instead of the string "Blueberry Smoothie: $4.99". The challenge is telling you that you need a space between the : and the $, and no space after the $ and before ${price}.