Why is this wrong? Help with Meal Maker

const menu = {

_courses  = {

appetizers: [],

  mains: [],

  desserts: [],

},

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.courses[courseName];

 const ram = 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 price = appetizer.price + main.price + dessert.price;

  return `Your meal is ${appetizer.name}, ${main.name}, ${dessert.name} which come to a total oof ${price} dollars`

}

};

menu.addDishToCourse('appetizers', 'Escargot', 10.00);

menu.addDishToCourse('appetizers', 'Calamari', 12.00);

menu.addDishToCourse('appetizers', 'Fries', 7.00);

menu.addDishToCourse('mains', 'Lobster', 22.00);

menu.addDishToCourse('mains', 'Lamb', 16.00);

menu.addDishToCourse('mains', 'Macaroni', 12.00);

menu.addDishToCourse('desserts', 'Rasberry Pie', 10.00);

menu.addDishToCourse('desserts', 'Pineapple Sorbet', 8.00);

menu.addDishToCourse('desserts', 'Chocolate Mousse', 12.00);

const meal = menu.generateRandomMeal();

console.log(meal);

I couldn’t get it right the first time so I copied it down exactly from the video. It was still wrong saying that there was a “syntax error: unexpected identifiers” where “desserts : this.desserts” in get courses is. What do I do?

Hi! Thanks for sharing your code and welcome to the forums.

The first step is to identify what the surface issues are: are there errors (what are they?), is a result not coming out the way you want it (what are the functions related to this error)? The more specific the question, the more the forum can help out!

what happened to const ram and the return statement afterwards?

1 Like

Thanks for that, that was wrong, but it still says there is a syntax error in the same place I stated before.

Thanks for that, that was wrong, but it still says there is a syntax error in the same place I stated before.

There’s a syntax error here if you can spot it… like the error message says, it’s around the word desserts.

return {

  appetizers: this.appetizers,

  mains: this.mains

  desserts: this.desserts

  };
1 Like

Thanks so much, I found all of the errors now and it is working properly!

1 Like

@irlfede did the heavy lifting :sweat_smile:

1 Like