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!

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 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

app.js
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}.