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

Sorin Chircu
Sorin Chircu
42,056 Points

I used double quotations mark for the string. as video says.The result shows me an error.I think this is not an issue.

I used double quotations mark for giving the value to a string variable but the system says me there is an error.I think this is not a problem becuase I only user "<h1>Strings are here</h1>" in this format.There should be a problem while compiling.If I am wrong,how can I solve this?

1 Answer

Shawn Jones
Shawn Jones
15,567 Points

Hi Sorin Chircu,

Yes, you are correct that it isn't a problem to assign a variable an HTML string using double quotes ("). Unfortunately, the question was looking for you to create a template literal string, which asks that you wrap the value with ticks (`) instead of double quotes so that any variables within the string can be processed. So, even though this is correct:

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

The engine was looking for an interpolated string like so:

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

As a quick reminder, template literals allow variables to be evaluated into values while nested in strings without the messiness of concatenation like so:

    let name = "Shawn"

    // concatenation
    let greeting = "Hello " + name;

    // vs.

    // template literal
    let alternativeGreeting = `Hello ${name}`;