Need help with menu maker


#1

i cant get this thing to work., i keep getting stack overflow error at return this.appetizers

const menu = {

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

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

set appetizers(appetizerIn){
this.appetizers= appetizerIn
},
set mains(mainsIn){
this.mains= mainsIn
},
set desserts(dessertsIn){
this.desserts=dessertsIn
},
},

////////////////////////////////////
get courses(){
return{
appetizers: this._courses.appetizers,
mains: this._courses.mains,
desserts: this._courses.desserts
}
},

addDishToCourse(courseName,dishName,dishPrice){
const dish = {
name:dishName,
price:dishPrice
}
this._courses[courseName].push(dish);
},
getRandomDishFromCourse: function (courseName) {
dishes= this._courses[courseName]
randomIndex= Math.floor(Math.random()*dishes.length)
return dishes[randomIndex]
},

generateRandomMeal : function(){
const appetizer =this.getRandomDishFromCourse(‘appetizers’)
const main=this.getRandomDishFromCourse(‘mains’)
const dessert=this.gentRandomDishFromCourse(‘desserts’)
const totalPrice= appetizer.price + main.price + dessert.price
return Your meal is ${appetizer.name}, ${main.name}, ${dessert.name}, and the total price of the meal is $${totalPrice}.
}
}

menu.addDishToCourse(‘appetizers’,‘nachos’, 4.25)
menu.addDishToCourse(‘appetizers’,‘cevice’,6.05)
menu.addDishToCourse(‘appetizers’,‘lettuce wraps’, 7.25)
menu.addDishToCourse(‘mains’,‘tacos’, 5.25)
menu.addDishToCourse(‘mains’,‘hamburger’, 6.25)
menu.addDishToCourse(‘mains’,‘cheese steak’, 9.35)
menu.addDishToCourse(‘desserts’,‘choclate cake’, 5.35)
menu.addDishToCourse(‘desserts’,‘cheesecake’,4.35)
menu.addDishToCourse(‘desserts’,‘ice cream’, 2.35)


#2

Those need to denoted as private properties…

_appetizers
_mains
_desserts

Those are all possible stack overflows…

this._appetizers = ...
this._mains = ...
this._desserts = ...

#3

#4