Hi! I’ve been doing the Meal Maker project and I have been stuck trying to find out what my error is.
I’ve been using other website JavaScript apps to see what my error is and they all point to the .push section of code on line 38. The problem is, I am not sure HOW to fix this and have my new inputs be moved into the dish variable.
My code is below:
const menu = {
_courses: {
appetizers: [],
mains: [],
desserts: [],
},
get courses() {
return {
appetizers: this.appetizers,
mains: this.mains,
desserts: this.desserts,
};
},
get appetizers() {
return this._course.appetizers;
},
set appetizers(appetizerIn) {
this._course.appetizers = 'appetizer';
},
get mains() {
return this._course.mains;
},
set mains(mainsIn) {
this._course.mains = 'main';
},
get desserts() {
return this._course.desserts;
},
set desserts(dessertsIn) {
this._course.desserts = 'dessert';
},
addDishToCourse(courseName, dishName, dishPrice) {
const dish = {
name: dishName,
price: dishPrice
};
this._courses[courseName].push(dish);
},
getRandomDishFromCourse: function() {
const dishes = this._courses[courseName];
const randomIndex = Math.floor(Math.random() * dishes.length);
},
generateRandomMeal: function() {
const appetizer = this.getRandomDishFromCourse('appetizers');
const main = this.getRandomDishFromCourse('mains');
const dessert = this.getRandomDishFromCourse('desserts');
const totalPrice = appetizer.price + main.price + dessert.price;
return `Your meal is ${appetizer.name}, ${main.name}, ${dessert.name}. The price for your meal tonight is $${totalPrice}`;
}
};
menu.addDishToCourse('appetizers', 'Miso', 3.50);
menu.addDishToCourse('mains', 'Sushi', 8.50);
menu.addDishToCourse('dessert', 'Tea', 4.00);
Thank you for your help and fresh pair of eyes!