Getters and Setters III


#1

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

https://www.codecademy.com/courses/learn-javascript-objects/lessons/objects/exercises/getters-setters-iii?action=lesson_resume&course_redirect=introduction-to-javascript

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>

Inside of the getter method, did you log the name and age of your person?

```

llet person = {
_name: ‘Lu Xun’,
_age: 137,

set age(newage) {
if (typeof newage === ‘number’)
{
this._age = newage;
}
else
{
return ‘Invalid input’;
}
},

get getAge() {
console.log(${this._name} is ${this._age} years old.);
return this._age;
},
};

person.age = ‘Thirty-nine’;
person.age = 39;
person.getAge;

<do not remove the three backticks above>

What i did wrong? I can't understand.

#2

you mispelled let here,


#3

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