Meal Maker Project: How can I use Setter method alternatively in addDishToCourse method?

const menu = {

_courses:{

appetizers:,

mains:,

desserts:

},

// courses property ends here

get appetizers(){

return this._courses.appetizers;

},

set appetizers (x){

return this._courses.appetizers = x;

},

get mains(){

return this._courses.mains;

},

set mains (x){

return this._courses.mains = x;

},

get desserts(){

return this._courses.desserts;

},

set desserts (x){

return this._courses.desserts = x;

},

get courses(){

return this._courses;

},

// Method

addDishToCourse(courseName,dishName,dishPrice){

const dish ={

dishName,

dishPrice

};

return courseName.push(dish) // How can I use setter method here???

}

};

So it took me a lot of reading on the forums and experimenting to finally figure out an alternative to using Setter but basically here it is. Use the setters to push items into each respective array.

set appetizers(app) {
    this._courses.appetizers.push(app);
  },
  set mains(main) {
    this._courses.mains.push(main);
  },
  set desserts(dessert) {
     this._courses.desserts.push(dessert);
  },

Then when creating the addDishToCourse method you can use the setters to add the dishes in this manner:

addDishToCourse(courseName, dishName, dishPrice) {
    const dish = {
      name: dishName,
      price: dishPrice
    };
      this[courseName] = dish;
  },

Let me know if that makes sense.