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?

Michael Hulet
Michael Hulet
Treehouse Moderator 46,972 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

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 51,734 Points

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.