Objects: Getters and setters I - Second test


#1

For some reason, this course won’t accept the perfectly functional code I submitted. Even when I ask for the solution, the only differences I see are the variables.

My code:

let person = {
  _name: 'Lu Xun',
  _age: 137,
	
  set age(newAge){
    
    if(typeof newAge === "number"){
       
      this._age = newAge;
       
    }else{
      
      console.log("Invalid input");
      return ("Invalid input");
    }
    
    
  }
};

Code that works for some reason:

let person = {
  _name: 'Lu Xun',
  _age: 137,
  
  set age(ageIn) {
    if (typeof ageIn === 'number') {
      this._age = ageIn;
    }
    else {
      console.log('Invalid input');
      return 'Invalid input';
    }
  }

};


#2

@oduffy can you take down this course not even kidding
…or at least I have no other response to this

It’s the quotes by the way.
“supposed” to be single quotes

tech-wise structured is kinda cool. But it’s a guessing game.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.