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 trialKJ Lee
1,059 PointsDoes anyone know what the template literal would be here?
const flavor = "Blueberry";
const type = "Smoothie";
const price = 4.99;
const drink = `${flavor} ' ' ${type} ':'' $' ${price}`;
2 Answers
Dmitry Polyakov
4,989 PointsTemplate literals are also called back ticks. On the keyboard they are above Tab If you want to get 'Blueberry Smothie: 4.99' the last line should go like this
const drink = ${flavor}${type} :${price}
;
For some reason they don't show here on this platform
Dmitry Polyakov
4,989 PointsFred, thanks for advice!
Fred Baker
4,061 PointsFred Baker
4,061 PointsThis isn't quite right. The correct answer is:
const drink = `${flavor} ${type}: $${price}`;
Make sure to add the template literal (`) to enclose the string, and each variables goes inside the interpolation ${}. Finally, you have to make sure the : is DIRECTLY behind the type variable and the $ is DIRECTLY before the price, with no spaces between the symbol and function (there is a space between the : and $).
KJ Lee
1,059 PointsKJ Lee
1,059 PointsThank you man!
Fred Baker
4,061 PointsFred Baker
4,061 PointsDmitry, it didn't for me at first either. when code is indicated, you have to use 3 backticks before and after the line so it captures everything inside as code.
KJ, sure thing!