JS Meal Maker help

This project keeps throwing me a TypeError on the return this._courses[courseName].push(dish); it’s been 30 mins and I can’t quite figure out what is wrong with my code, I would really appreciate the help :slight_smile:

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, dessert: this.dessert, }; }, addDishToCourse(courseName, dishName, dishPrice) { const dish = { name: dishName, price: dishPrice, }; return this._courses[courseName].push(dish); }, getRandomDishFromCourse(courseName) { const dishes = this._courses[courseName]; const randomIndex = Math.floor(Math.random() * dishes.length); return dishes[randomIndex] }, generateRandomMeal: function() { const appetizer = this.getRandomDishFromCourse('appetizers'); const mains = this.getRandomDishFromCourse('mains'); const desserts = this.getRandomDishFromCourse('desserts'); const totalPrice = appetizer.price + mains.price + desserts.price; return `Your meal is ${appetizer.name}, ${main.name}, ${dessert.name} the price is ${totalPrice}.` } }; menu.addDishToCourse('appetizers', 'Caesar Salad', 4.25); menu.addDishToCourse('appetizers', 'Calamari', 5.70); menu.addDishToCourse('appetizers', 'Caprese Salad', 4.60); menu.addDishToCourse('mains', 'Pork Chops', 12.50); menu.addDishToCourse('mains', 'Filet Mignon', 15.30); menu.addDishToCourse('mains', 'Salmon', 13.25); menu.addDishToCourse('dessert', 'Bananas Foster', 6.45); menu.addDishToCourse('dessert', 'Creme Brulee', 5.75); menu.addDishToCourse('dessert', 'Tiramisu', 4.55); let meal = menu.generateRandomMeal(); console.log(meal);

we can log the keys and available keys to see what might be the problem:

  addDishToCourse(courseName, dishName, dishPrice) {
    const dish = {
      name: dishName,
      price: dishPrice,
    };
    console.log(Object.keys(this._courses), courseName);
    return this._courses[courseName].push(dish);
  },
2 Likes

it actually helped me out plenty! I typed ‘dessert’ instead of ‘desserts’ in a bunch of spots, thank you so much!