JavaScript JavaScript Basics Working with Strings Combine Strings and Template Literals Review

B V K Mahijendra
B V K Mahijendra
9,133 Points

template literal

Quiz Question 2 of 6 Please fill in the correct answer in each blank provided below.

Fill in the blank(s) below:
Complete the code below to create a template literal:

const headline =-- <h1>A Literal Headline</h1>--;

5 Answers

const drink = `${flavor} ${type}: $${price}`;
James Barshaw
James Barshaw
4,166 Points

this is not the right answer I have tried it in many ways and it doesn't work

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 89,590 Points

To make a template literal, you use the backtick characters... like this ` `.

let templateLiteral = `this is 
a template
literal
`;
B V K Mahijendra
B V K Mahijendra
9,133 Points

Convert 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} ; ( this ain't working, could you help me with this? )

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 89,590 Points

Well, you've got the interpolation syntax just right. :)

You're missing the characters to actually make the template literal string.

Look carefully at what the example is saying. With these kinds of challenges, you have to get the string output just right as the code behind the scenes is looking for something specific! :-)

Good luck!

Back Ticks before and at end before;