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 trialstarr13
2,494 PointsAre there anyone having trouble getting the template literal final string "Blueberry Smoothie: $4.99? I'm having trouble
const flavor = "Blueberry";
const type = "Smoothie";
const price = 4.99;
const drink = flavor + ' ' + type + ': ' + '$' + price;
const drink =`${flavor}${type}: $${price};`
1 Answer
Brandon White
Full Stack JavaScript Techdegree Graduate 35,771 PointsHi Julia,
Your code looks really good for the most part, but I see three things that will cause issues for you. One is that you've included the semi-colon (which in this case is meant to signal the end of a statement) inside your string (which would throw off the test code that's evaluating the challenge). Another thing is that you don't currently have a space between the ${flavor} and ${type} in your template string. And lastly, because you've already defined the variable drink as a const on line 5, you can't redeclare it on line 6 (that would result in an error). In fact, because the variable is a const variable, you can't even assign it a different value.
That said, I understand the value of not always deleting code when you're first learning (just in case you make a mistake, you can go back to the original version). If you don't want to change the code the challenge has given you directly, you can always comment out the part of the code that you will be altering using the following syntax: //
<= This tells the interpreter to ignore everything on the same line that comes after that symbol.
Hope that helps. =)
LaShawna Thomas
1,845 PointsLaShawna Thomas
1,845 PointsHow do you add a space in between ${flavor} and ${type}???
Brandon White
Full Stack JavaScript Techdegree Graduate 35,771 PointsBrandon White
Full Stack JavaScript Techdegree Graduate 35,771 PointsHi LaShawna,
You would just leave a space between the two templates, like so:
`${flavor} ${type}`
Have I misunderstood your question, or does βπΎthat answer it for you?