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 trialKhatia Bagaturia
2,050 Pointscan you guys explain what is my mistake .
I am trying to concatenate string and it looks complicated . Please help me !
const flavor = "Blueberry";
const type = "Smoothie";
const price = 4.99;
const drink = flavor + $( 'Blueberry ' ) + type + $( 'Smoothie: ') + ( '$4.99' ) + price;
// "Blueberry smoothie: 4.99;"
Steven Parker
231,275 PointsFYI: Without using Markdown formatting, you need to "escape" backticks to make them show:
const drink = `${flavor} ${type}: $${price}`;
1 Answer
Steven Parker
231,275 PointsYou need to use the variables by name instead of the replicating their contents.
But you also need to choose whether to use a template literal or concatenation. What is shown here is a mix of the syntax of both those methods but is not correct for either.
Khatia Bagaturia
2,050 Pointsok ! thanks you
redtheology
2,605 Pointsredtheology
2,605 PointsSteven is correct that you cannot combine the two. I think this exercise is looking for you to use template literal syntax with interpolation. As an example, I pasted the two options you can take to accomplish the task (either template literal or concatenation). Happy coding!
const flavor = "Blueberry"; const type = "Smoothie"; const price = 4.99;
//do this to use template literal with interpolation
const drink =
${flavor} ${type}: $${price}
; console.log(drink);//or do this to use concatenation
const drink = flavor + " " + type + ": " + "$" + price console.log(drink);