Meal Maker Headache

So, I’ve hit a wall with the Meal Maker project. Here’s my code:

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(appIn){
    this._courses.appetizers.push(appIn);
  },
  set mains(mainIn){
    this._courses.mains.push(mainIn);
  },
  set desserts(desIn){
    this._courses.desserts.push(desIn);
  },
  get courses(){
    return{
      appetizers: this.appetizers,
      mains: this.mains,
      desserts: this.desserts,
    }
  },
  addDishToCourse(courseName, dishName, dishPrice){
    const dish = {
      name: courseName,
      price: dishPrice,
    };
    this._courses[courseName].push(dish);
  },
  getRandomDishFromCourse(courseName){
    const dishes = this._courses[courseName];
    const randomIndex = Math.floor(Math.random()*dishes.lengh);
    return dishes[randomIndex];
  },
  generateRandomMeal(){
    const appetizer = this.getRandomDishFromCourse("appetizers");
    const main = this.getRandomDishFromCourse("mains");
    const dessert = this.getRandomDishFromCourse("desserts");
    const mealPrice = appetizer.price + main.price + dessert.price;
    return `Your meal is ${appetizer.name}, ${main.name} and ${dessert.name}. The total price is ${mealPrice}.`;
  },
}

menu.addDishToCourse("appetizers", "Salad", 4.00);
menu.addDishToCourse("appetizers", "Cheese Sticks", 5.50);
menu.addDishToCourse("appetizers", "Chicken Wings", 4.50);
menu.addDishToCourse("mains", "Sirloin", 20.00);
menu.addDishToCourse("mains", "Bourbon Street Chicken", 18.00);
menu.addDishToCourse("mains", "Turkey Club", 15.00);
menu.addDishToCourse("desserts", "Ice Cream", 8.00);
menu.addDishToCourse("desserts", "Cake", 5.00);
menu.addDishToCourse("desserts", "Mochi", 6.00);

let meal = menu.generateRandomMeal();

console.log(meal);




And my error message is:

I’ve gone through the code a billion times and through the walkthrough video and I just can’t find the issue. Thank you so much for the help.

Hello, @jldstraylight! Welcome to the Codecademy Forum!
Having taken a quick glance at your code, nothing sticks out. If you wouldn’t mind reposting the code part of your post using the </> button, so we can copy, and run your code ourselves that would help immensely. Click the </> first, and then paste your code from the lesson in the space provided. It preserves format and special characters. If I try to copy and run your code as is, I have to replace all of the 's, many of the quotation marks and the back tics. Thanks!

Using the </> makes your code look like this:

const name = 'midlindner';
console.log(`Hello ${name}!`);

Sorry about that. Main post edited to include the right code posting thingy.

1 Like

Okay. Couple of itty bitty mistakes:

2 Likes

Yay! That worked. You’re a wizard. Thank you.

1 Like