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 trial

JavaScript Getting Started With ES2015 Using Template Literals String Interpolation

I can't get interpolation to work. I typed it out like in the video, but when I refreshed the page, nothing appeared.

nothing appears in the interpolation slot in the template literals tab even though I have typed it out exactly like in the video. what's going on?

What does the console say?

Michael Hulet
Michael Hulet
47,912 Points

Can you paste the code you're having trouble with here? It'd help us a lot if we could see your code and try it ourselves

3 Answers

You are missing a few backticks

function like(thing) { return 'I like ' + thing; }

function love(thing) { return `I love ${thing}` ; } //after ${thing} here

const sentence = `<p>${like('apples')}, but ${ love('oranges')}.</p>`;  //before <p> and after </p> here

document.querySelector('.interpolation').innerHTML = sentence;

here it is.

function like(thing) { return 'I like ' + thing; }

function love(thing) { return `I love ${thing} ; }

const sentence = <p>${like('apples')}, but ${ love('oranges')}.</p>;

document.querySelector('.interpolation').innerHTML = sentence;

I tried to make it exactly like the teacher showed in the video, and I'm pretty sure it is exactly the same. But for some reason it didn't work when I viewed it. Thank you for responding.

Thanks. I hadn't noticed that.