JavaScript Getters and Setters


I’m on the second-to-last portion of the Objects section, doing Getters and Setters. It says I did the code correctly (it’s passing the instructions), but when I run it, I get a huge error. My code within the already provided name object for the getter looks like this:
get age () {
console.log(${} is ${person.age} years old.);
return this._age;
and of course the console log code looks like:

Again, not sure what to do, because codecademy says I’m correct, while the console gives me a huge error that says the RangeError: Maximum call stack size exceeded. ???


Your property refers to itself, each time it’s called, it’ll call itself. This won’t stop until the program crashes due to the call stack getting too large.


So what should the code be? The instructions passed me, so I couldn’t get it to give me the code correctly so that it wouldn’t cause that error.


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