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 Object-Oriented JavaScript Getters and Setters Object Interaction

errors after class Owner

class Pet {
constructor(animal, age, breed, sound){
this.animal = animal;
this.age = age;
this.breed = breed;
this.sound = sound;


 get activity(){
  const today = new Date();
  const hour = today.getHours();

  if (hour > 8 && hour <=20) {
return "playing";

} else {

return "sleeping";
} // end of else

} // end of get activity

get owner (){
return this._owner;

set owner (owner) {
this._owner = owner;
console.log( `setter called: ${owner}`); 

 speak() {

} // end of speak

} // end of class

class Owner {
 constructor(name, address) {
 this.name = name;
 this.address = address;
 set phone(phone) {
const phoneNormalized = phone.replace(/[^0-9]/g, '');
  this._phone = phoneNormalized;
  get phone(){
  return this._phone;

const ernie = new Pet ("dog",1,"pug","woof woof");
ernie.owner = new Owner("ashley", "112 via aurelia");

Receiving errors on console after adding owner

    at createScript (vm.js:80:10)                                             
    at Object.runInThisContext (vm.js:139:10)                                 
    at Module._compile (module.js:617:28)                                     
    at Object.Module._extensions..js (module.js:664:10)                       
    at Module.load (module.js:566:32)                                         
    at tryModuleLoad (module.js:506:12)                                       
    at Function.Module._load (module.js:498:3)                                
    at Function.Module.runMain (module.js:694:10)                             
    at startup (bootstrap_node.js:204:16)                                     
    at bootstrap_node.js:625:3                                                

1 Answer

Dario Bahena
Dario Bahena
10,697 Points

Might be your browser, refresh it or restart it. It's not an issue with your code since your code works in my environment.