I am doing the “Meal Maker” challenge in the Javascript course. I am close to completing it, plus I watched the associated video. I cannot understand why there is an error on line 37. The error says the “push” property can’t be identified by I can’t understand why. Thanks!
const menu = {
_courses: {
appetizers: [],
mains: [],
desserts: [],
},
get appetizers() {
return this._courses.appetizers;
},
get mains() {
return this._courses.mains;
},
get deserts() {
return this._courses.deserts;
},
set appetizers(appetizers) {
return this._courses.appetizers = appetizers;
},
set mains(mains) {
return this._courses.mains = mains;
},
set deserts(deserts) {
return this._courses.deserts = deserts;
},
get courses() {
return {
appetizers: this.appetizers,
mains: this.mains,
deserts: this.deserts
};
},
addDishToCourse(courseName, dishName, dishPrice) {
const dish = {
name: dishName,
price: dishPrice,
};
return this._courses[courseName].push(dish);
},
getRandomDishFromCourse(courseName) {
const dishes = this._courses[courseName];
const randomIndex = Mathl.floor(Math.random(dishes.length))
return dishes[randomIndex];
},
generateRandomMeal() {
const appetizer = this.getRandomDishFromCourse('appetizers');
const mains = this.getRandomDishFromCourse('mains');
const desert = this.getRandomDishFromCourse('deserts');
const totalPrice = appetizer.price + main.price + deserts.price;
return `Your meal is ${appetizer.name}, ${main.name}, and ${desert.name} The price is ${totalPrice}.`;
}
};
menu.addDishToCourse('mains','hamburger',10);
menu.addDishToCourse('mains','sandwich',10);
menu.addDishToCourse('mains','steak',10);
menu.addDishToCourse('appetizers','salad',8);
menu.addDishToCourse('appetizers','chips',8);
menu.addDishToCourse('appetizers','soup',8);
menu.addDishToCourse('deserts','cookie',4);
menu.addDishToCourse('deserts','cake',4);
menu.addDishToCourse('deserts','ice cream',4);
const meal = menu.generateRandomMeal();
console.log(meal);