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 trialMatias Ikonen
523 PointsbeConvert the set of concatenated strings assigned to the drink variable to a template literal. The final string should
Need help with this one.. Convert the set of concatenated strings assigned to the drink variable to a template literal. The final string should be "Blueberry Smoothie: $4.99".
const flavor = "Blueberry"; const type = "Smoothie"; const price = 4.99;
const drink = ${flavor} ${type}:$ ${price}.
Bummer: Make sure you're including : $
immediately after type
and before price
.
16 Answers
Steven Parker
231,154 PointsWhen posting code to the forum, use Markdown formatting to preserve the appearance. And providing a link to the challenge would be helpful also.
But without referencing the challenge itself, it looks like this code will place a space between the dollar sign and the price; but the challenge might be expecting a space between the colon and dollar sign but not before the price. Also notice that the period that ends the sentence is not part of the string to be output.
PAKU DAS
Full Stack JavaScript Techdegree Student 999 PointsThis worked
const drink = ${flavor} ${type}: $${price}
;
Shanna vick-Morris
6,683 Pointsconst drink = ${flavor} ${type}: $${price}
;
Steven Parker
231,154 PointsYou both need formatting for your symbols to show up. See the video linked in my original answer.
Strange Thomas
2,139 PointsNone of these are working!!
Shanna vick-Morris
6,683 PointsStrange Thomas you need to use a back tick before and after my answer above.
Steven Parker
231,154 PointsAnd the formatting I mentioned in my original answer is necessary to show the back-ticks in the forum!
FRANKIE Ochoa
2,759 Pointsyeah I'm pretty lost I'm stuck on this someone please help
Asadsami Beldo
Full Stack JavaScript Techdegree Student 4,560 PointsI removed the concatenated string and this worked const drink = ${flavor} ${type}: $${price} ; Because const cannot be renamed you would get an error. Cant have const drink for the string and const drink for the templet literal.
Elene Akers
4,161 Pointsyou have to delete the line above
Mike Siwik
Full Stack JavaScript Techdegree Student 8,483 PointsThis was a fun code challenge. I see everyone using const, but
let drink = `${flavor} ${type}: $${price};
passes. Commenting out the above line also works
jordan gillispie
24,414 PointsThe value of the third variable is an integer and its asking for you to place a $ before the third var. check your spacing as well as the necessary piece of syntax to create a template literal. ill give one more hint the syntax piece is similar to a "" I hope this helps! Best of luck
James Barshaw
4,167 PointsI have tried this answer in many different ways and it doesn't work
Samuel Buta
2,403 Pointsconst drink = ${flavor} ${type}: $${price}
; Try this it works.
edgar robledo
6,067 Pointsthis does not work why please explain.
const drink = ${flavor} ${type + ':'} ${'$' + price}
;
the log is = Blueberry Smoothie: $4.99
Pascal El Murr
2,577 PointsWhile using template literals you can't write any thing inside ${type} for example, it only takes the variable declared try to review the Template Literal course. But this is the best way to write it :
const drink = ${flavor} ${type}: $${price};
Steven Parker
231,154 PointsActually, you can write any expression inside the template token. And technically, your example does work to create the intended string, but it's rather unconventional and perhaps not as easy to read.
The challenge checker is apparently looking specifically for the more conventional approach to be used, and not simply testing the end result or this would pass.
And in future, rather than post a question as an "answer" to another one, create a fresh new question for your own.
Palash Tiwari
8,050 Pointsbecause in this one we are supposed to use `` and the whole purpose of using it is to simplify things by removing all those + signs
the answer will be
const drink = ${flavor} ${type}: $${price}
;
Anika Heinrich
Front End Web Development Techdegree Student 1,944 Pointsconst flavor = "Blueberry"; const type = "Smoothie"; const price = 4.99;
const drink = '${flavor} ${type}: $${price}' ;
You need this ' '
Steven Parker
231,154 PointsIt actually needs accents (backticks), not apostrophes.
This ` … not this '
But they won't show up in the forum unless you use formatting. See the video linked in my original answer.
Dane Edwards
675 PointsThis should be right.
const drink = ${flavor} ${type}: $${price}
;
Steven Parker
231,154 PointsLike PAKU and Shanna, you need formatting for your symbols to show up. See the video linked in my original answer.
Jmaisin Williams
8,263 Pointsi tried them all none of them work
Steven Parker
231,154 PointsSee the code example left by dariuszkostrzewski in his comment to my original answer.
realedwardleung
7,197 Pointsconst drink = ${flavor} ${type}: $${price}
;
Steven Parker
231,154 PointsSee the comments about formatting in my original answer.
Marlon Baker
Full Stack JavaScript Techdegree Student 837 PointsThank you guys i was stuck too
Sabrina Shields
Web Development Techdegree Student 12,830 Pointsconst flavor = "Blueberry";
const type = "Smoothie";
const price = 4.99;
const drink = '${flavor} ${type}: $${price}';
Violet Sky
5,224 Pointsin the example, it provides the following:
const flavor = "Blueberry"; const type = "Smoothie"; const price = 4.99;
const drink = flavor + ' ' + type + ': ' + '$' + price;
you have to delete the line 'const drink = flavor + '' + type + ':' + '$' + price; '
once you delete the line, then you can redeclare it as a template literal as follows
const drink = ${flavor} ${type}: $${price}
;
that's it.
Harold Datus
Front End Web Development Techdegree Graduate 13,412 Pointsconst drink = ${flavor} ${type}: $${price}
;
Pascal El Murr
2,577 Pointsconst flavor = "Blueberry"; const type = "Smoothie"; const price = 4.99;
const drink = ${flavor} ${type}: $${price}
;
this will work :)
B V K Mahijendra
9,133 Pointsconst flavor = "Blueberry"; const type = "Smoothie"; const price = 4.99;
const drink = ${flavor} ${type}: $${price}
;
this aint't working..
could anyone help me with this.
Steven Parker
231,154 PointsRead my comments to Edgar and Pascal from Mar 10!
dariuszkostrzewski
9,409 Pointsdariuszkostrzewski
9,409 PointsHi,
Exactly. The following code is correct:
const drink = `${flavor} ${type}: $${price}`;
Mauricio Hernandez
7,208 PointsMauricio Hernandez
7,208 Pointsdariuszkostrzewski thank you, blessings. John 3:16 (NIV). Jesus loves you.