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 trialSorin Chircu
45,432 PointsI 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
15,579 PointsHi 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}`;