Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Object-Oriented JavaScript Getters and Setters Setters

AJ Jhaveri
seal-mask
.a{fill-rule:evenodd;}techdegree
AJ Jhaveri
Full Stack JavaScript Techdegree Student 512 Points

String 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

It 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}`

Here is an MDN article and a page from Stack Overflow.