Meal Maker price is undefined

Hello guys, I am having issues with the meal maker, this is the error I am getting
** const totalPrice = appetizer.price + main.price + dessert.price;

TypeError: Cannot read property ‘price’ of undefined**

I cant seem to find the mistake, I have looked at others people code to see if I can figure it out, but I am still struggling, any help would be appreciated


const menu = {
  _courses: {
    appetizers: [],
    mains: [],
    desserts: []
  // setters and getters for the 3 items 
  get appetizers() {
    return this._courses.appetizers;
  get mains() {
    return this._courses.mains;
  get desserts() {
    return this._courses.desserts;
  set appetizers(newAppetizer) {
    this._courses.appetizers = newAppetizer;
  set mains(newMains) {
    this._courses.mains = newMains;
  set desserts(newDesserts){
    this._courses.desserts = newDesserts;

  get courses() {
    return {
      appetizers: this.appetizers,
      mains: this.mains,
      desserts: this.desserts
  addDishToCourse(courseName, dishName, dishPrice) {
    const dish = {
      name: dishName,
      price: dishPrice
  getRandomDishFromCourse(courseName) {
    const dishes = this._courses[courseName];
    const randomNum = Math.floor(Math.random() * dishes.lenght);
    return dishes[randomNum];
    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 ${}, ${}, ${} the price is $${totalPrice}.`;

menu.addDishToCourse('mains', 'Chicken Wings', 5);
menu.addDishToCourse('appetizers', 'Chicken Alfredo', 10);
menu.addDishToCourse('desserts', 'Chocolate Mousse', 5);
menu.addDishToCourse('mains', 'Chicken Tikka Masala', 5);

const meal = menu.generateRandomMeal();


First off, are we sure what undefined means or indicates? (Not asked facetiously)

No worries at all, trial and error is how you learn, and if I am not mistaken, it means it has no value or is not defined,

I was looking at that, I went through it, when the addDishToCourse is call it has its value, which is pass to the dishPrice and ends up in the price key.

I just don’t see where it glitches. there is something I am missing


But it is defined, we would espouse; yet it isn’t, not the way the interpreter sees it. That means we must trace back where the variable is derived and sourced. That’s debugging. Have a pleasant experience. Feel the buzz.

Hi mtf,

so yeh, I been staring at my code for the last 2 hours, tracing it from beginning to end trying to find the issue, found a few miss typed items, But I have not been able to find the error with the price, could you point me to what exactly I am doing wrong?

Might we expect this is now corrected?