Start by adding an empty .age() setter method


Ok, forums are a little weird right now, the links to forums aren’t working and doing a site search didn’t show a result so apologies if I’m not finding a previous thread on this. Also apologies on the makeshift category, wasn’t finding the option for this specfic one.

I’d like to understand and complete this step 1 on Getters and setters I. How does it work? Tried many variatons and not making sense of it. also, “Get code” didn’t make this step clear either, just breezed past it. As follows, how would this work?:


Start by adding an empty .age() setter method.



Please post a link to the exercise. Thanks.

Your object may look something like this:

const person = {
    _name = "Wee Gillis",
    _age = 19

To add setter method, write it inside the object,

const person = {
    _name = "Wee Gillis",
    _age = 19,
    set age {


The setter for _name will be written the same way.

Setters need getters, so I expect the next lesson, or next step, will be to add the getters.

Use this example to help you along. If you still have questions, ping this topic.


Thanks, that’s what I was thinking but it doesn’t like that for some reason, though it asks for it. This is that exercise


Try writing it with the () which I accidentally left out. Sorry.

    set age() {


There will be a parameter, newAge but the instructions don’t say to add it in step 1. Step 2 will need it since it has to validate the input.

    set age (newAge) {



Thank you! I must be understanding it ok so far, these are all things I’d tried before posting. It will work only with the newAge pass, it warns me without it:

SyntaxError: Setter must have exactly one formal parameter.

I’d tried passing that before posting but my flaw was forgetting to add a comma at the end of the preceding keys. ( _age: 137, ) - which was keeping me from getting the clearer error message above.

Thanks for the guidance, helped me on my way troubleshooting.


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