I can’t figure out why appetizers is giving back an undefined error or where it’s causing the error please help!
const menu = {
_courses : {
aappetizers: [],
mains: [],
desserts: [],
},
get appetizers(){
return this._courses.appetizers
},
get mains(){
return this._courses.mains;
},
get desserts(){
return this._courses.desserts;
},
set appetizers(appetizers) {
this._couses.appetizers = appetizers;
},
set mains(mains) {
this._couses.mains = mains;
},
set desserts(desserts) {
this._couses.desserts = desserts;
},
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[_courses];
const randomIndex = math.floor(math.random() * dishes.length);
return dishes[randomIndex];
},
generateRandomMeal() {
const appetizer = this.getRandomDishFromCourse('appetizers');
const main = this.getRandomDishFromCourse('mains');
const dessert = this.getRandomDishFromCourse('desserts');
const totalPrice = appetizers.price + main.price + dessert.price;
return `your meal is ${appetizer.name}, ${main.name}, and ${dessert.name} and the total price is ${totalprice} `;
}
};
menu.addDishToCourse('appetizer ' , 'soup ', 4.00);
menu.addDishToCourse('appetizer ', 'wings ', 4.50);
menu.addDishToCourse('appetizer ', 'mash ', 3.00);
menu.addDishToCourse('main ', 'triple dipper ', 10.00);
menu.addDishToCourse('main ', 'pizza ', 10.00);
menu.addDishToCourse('main ', 'chicken ', 10.00);
menu.addDishToCourse('dessert ', 'cookie ', 1.00);
menu.addDishToCourse('dessert ', 'cake ', 3.00);
menu.addDishToCourse('dessert ', 'lava cake ', 2.50);
let meal = menu.generateRandomMeal();
console.log(meal);
You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility