Meal Maker Project

Hello, Codecademy Community! :slight_smile:
I am stuck on the Meal Maker Project because I keep getting the error:

/home/ccuser/workspace/learn-javascript-objects-meal-maker/app.js:20 return this._courses.desserts; ^ TypeError: Cannot read property 'desserts' of undefined at Object.get desserts [as desserts] (/home/ccuser/workspace/learn-javascript-objects-meal-maker/app.js:20:27) at Object.addDishToCourse (/home/ccuser/workspace/learn-javascript-objects-meal-maker/app.js:38:18) at Object.<anonymous> (/home/ccuser/workspace/learn-javascript-objects-meal-maker/app.js:54:6) at Module._compile (module.js:571:32) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Module.runMain (module.js:605:10) at run (bootstrap_node.js:427:7)

Here is the link to my work so far:
https://gist.github.com/5a73475bfdfff2941ab427ee04b9851d
Thank You!

1 Like

It has to do with context…

  _courses: {
    appetizers: [],
    mains: [],
    desserts: [],

    get appetizers() {
      return this._courses.appetizers;
    },
    set appetizers(appetizers) {
      this._courses.appetizers = appetizers;
    },
    get mains() {
      return this._courses.mains;
    },
    set mains(mains) {
      this._courses.mains = mains;
    },
    get desserts() {
      return this._courses.desserts;
    },
    set desserts(desserts) {
      this._courses.desserts = desserts;
    },
  },

Due to their placement,

    get mains () {
        return this._mains
    },
    set mains (main) {
        this._mains.push(main)
    }

Mind that means writing the courses as backing variables else the above will result in circular references.

At any length, be sure you are addressing the right context. Some preliminary testing will help.