Hey guys
I’ve been combing this desert for an hour now and still cant figure out why been given an error rather then run it
I’m testing to see if my functions worked but rather then execute the functions im getting a type error
Currently at step 12 of the exercise
here’s a screencap of the error given
below is my code
let menu ={
_courses:{
appetizers:[],
mains:[],
desserts:[],
get appetizers () {
return this._courses.appetizers;
},
get mains () {
return this._courses.mains;
},
get desserts () {
return this._courses.desserts;
},
set appetizers (appetizer){
this._courses.appetizers = appetizer;
},
set mains (main){
this._courses.mains = main;
},
set desserts (dessert){
this._courses.desserts = dessert;
},
get courses (){
return {
appetizers: this.appetizers,
mains:this.mains,
desserts:this.desserts,
}
},
addDishToCourse (courseName,dishName,dishPrice){
const dish ={
name: dishName,
price: dishPrice,
};
return this._courses[courseName].push(dish);
},
getRandomDishFromCourse(courseName){
const dishes =this.courses[courseName];
const randNum = Math.floor(Math.random()*dishes.length);
return dishes[randNum];
},
generateRandomMeal(){
const appetizer =this.getRandomDishFromCourse('appetizers');
const main =this.getRandomDishFromCourse('mains');
const dessert =this.getRandomDishFromCourse('desserts');
const totalPrice = appetizer.price +main.price+dessert.price;
return `The order of ${appetizer} ${main} and ${dessert} will cost a total of ${totalPrice}`;
}
}
};
console.log(menu._courses);
menu.addDishToCourse('appetizers','Eggroll',2);
addDishToCourse('mains','General Tzo Chicken',10);
addDishToCourse('desserts','Furtune cookies',1);
console.log(menu._courses);
Thnks!