Meal Maker Project: Cannot read property 'push' of undefined

I’ve been working on the Meal Maker project in the JavaScript Objects section. For some reason, the .push() method keeps causing errors in my getters and the addDishToCourse() method.

I’ve read all of the threads related to this problem on Codecademy, but nothing seems to be working.

Here is my code:

_appetizers (and _mains and _desserts) are properties of courses object, as such, the getter and setter methods for appetizers should be in the courses object:

  _courses: {
    _appetizers: [],
    _mains: [],
    _desserts: [],
    get appetizers(){
        return this._appetizers;

you can’t just return a string, the getters are used every time we try to read the property, the getter is used here:


so you want the array, not some string

1 Like

Since we’re calling the getter, we may as well call the setter, too.

this._courses[courseName] = dish;

The setter has its own push method call.


Thank you! Here’s my final code for anyone who has the same question in the future:

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