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 trialAJ Jhaveri
Full Stack JavaScript Techdegree Student 512 PointsString interpolation for setter video example not working.
I'm not getting the owner string for ${owner} in the setters oojs video example.. any ideas? syntax is the exact same as in the video. the string interpolation is not occurring for some reason.
I have:
set owner(owner) {
this._owner = owner;
console.log('setter called: ${owner}');
}
but am getting the following in my console:
[after] treehouse:~/workspace$ node Pet.js
setter called: ${owner}
This works fine: console.log('setter called:' + owner); but not console.log('setter called: ${owner}'); for some reason.
3 Answers
KRIS NIKOLAISEN
54,972 PointsIt looks like you are using single quotes instead of backticks. The backtick key is to the left of the number 1 key.
This:
'setter called: ${owner}'
should be this:
`setter called: ${owner}`
AJ Jhaveri
Full Stack JavaScript Techdegree Student 512 Pointswhy backticks? I thought we have always used single or double quotes in the past.
AJ Jhaveri
Full Stack JavaScript Techdegree Student 512 PointsThank you though. I'll read up on it! :)
KRIS NIKOLAISEN
54,972 PointsHere is an MDN article and a page from Stack Overflow.