This project ‘meal maker’ is very overwhelming
Till now I had this problem
this is the whole code:
const menu = {
_courses: {
appetizers: [],
mains: [],
desserts: [],
get appetizers() {
return this._courses.appetizers;
},
set appetizers(appetizerIn) {
this._courses.appetizers = appetizerIn;
},
get mains() {
return this._courses.mains;
},
set mains(mainsIn) {
this._courses.mains = mainsIn;
},
get desserts() {
return this._courses.desserts;
},
set desserts(dessertsIn) {
this._courses.desserts = dessertsIn;
}
},
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 index = Math.floor(Math.random() * dishs.length());
return dishes[index];
},
generateRandomMeal() {
const appetizer = this.getRandomDishFromCourse('appetizers');
const main = this.getRandomDishFromCourse('main');
const dessert = this.getRandomDishFromCourse('dessert');
const totalPrice = appetizer.price + main.price + dessert.price;
return `Your meal is ${appetizer.name}, ${main.name}, ${dessert.name} and the price is ${totalPrice}.`
}
};
menu.addDishToCourse(‘appetizers’, ‘salad’, 10);