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 trialSimon Sporrong
35,097 PointsCan't get the interpolation to work
Hi!
I'm trying to complete this step but can't get the interpolation to work.
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;
What am i doing wrong? I am using google chrome as a browser. The browser will just print "I like ${thing} but I love ${thing}. Please help :)
2 Answers
Samuel Zhen
33,571 PointsYou have to use backtick as well in your like and love function. When you use the single quote, you literally returning a I like ${thing} string.
function like(thing) {
return `I like ${thing}`;
}
function love(thing) {
return `I love ${thing}`;
}
Simon Sporrong
35,097 PointsYeah, i figured that out at last. Thank you for helping, Samuel :) I'm the dumbest boy in school.
Steve Mustanski
15,093 PointsEveryone makes mistakes like that when learning.