Stuck on Meal Maker

I’ve spent a crazy amount of time trying to figure out where I went wrong here, could somebody help?
Thanks!
Full Code :
const menu = {
_courses: {
appetizers:,
mains:,
desserts:,
get courses() {
return ;
}
},
get appetizers() {
return this._courses.appetizers;
},
get mains() {
return this._courses.mains;
},
get desserts() {
return this._courses.desserts;
},
set appetizers(appetizers) {
this._courses.appetizers = appetizers;
},
set mains(mains) {
this._courses.mains = mains;
},
set desserts(desserts) {
this._courses.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._course[courseName];
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 = appetizer.price + main.price + dessert.price;
return Your meal is ${appetizer.name}, ${main.name}, and ${dessert.name}, and the total price is ${totalPrice};
}
};
menu.addDishToCourse(‘appetizers’, ‘salad’, 4.00);
menu.addDishToCourse(‘appetizers’, ‘wings’, 8.00);
menu.addDishToCourse(‘appetizers’, ‘cheese dip’, 6.00);

menu.addDishToCourse(‘mains’, ‘ribs’, 16.00);
menu.addDishToCourse(‘mains’, ‘chicken’, 12.00);
menu.addDishToCourse(‘mains’, ‘fish’, 12.00);

menu.addDishToCourse(‘desserts’, ‘ice-cream’, 3.00);
menu.addDishToCourse(‘desserts’, ‘cake’, 6.00);
menu.addDishToCourse(‘desserts’, ‘chocolate’, 4.00);

const meal = menu.generateRandomMeal();
console.log(meal);

In your addDishToCourse() method, you don’t want to return the dish object to the caller. You are pushing the dish to its respective array inside the _courses object. Just leave the word return out.

1 Like

@stevencopeland Just realized you are referring to the single quotes inside the menu.addDishToCourse('appetizers', 'salad, 4.00); and etc. The single quotes will work fine. Not sure why they look a little odd, but it’s not the first I’ve seen of them.

@midlindner
laughs awkwardly hehe… hehe… deletes post
I thought for some reason he used the ` when he called the function.

I see what you mean though. I tried copying his code to an online code tester, and the single quotes have to be changed to work. Kinda strange.

1 Like

Also, you have a spelling error in this method:

getRandomDishFromCourse(courseName){
const dishes = this._course[courseName]; //this._courses[courseName];
const randomIndex = Math.floor(Math.random() * dishes.length);
return dishes[randomIndex];
},
1 Like

No worries. I assume those odd looking single quotes work on his local machine on the Codecademy site, but they aren’t recognized universally. May be a regional or country specific character?

huh, yeah that’s probably it… I’ve seen like, my grandparents from Romania’s computers and they sometimes have stuff like that.

1 Like

We should use a singular term in the parameters, and not the same name as the property.

set appetizers (appetizer) {
    this._courses.appetizers.push(appetizer)
}
1 Like

Thank you, appreciate the help!

1 Like