Trying to finish this project but an unexpected error came

I tried looking through the walkthrough, copied the stuff, but it’s still the same error :frowning:

Meal Maker
Error

So I see the following error:

Uncaught TypeError: this._courses[courseName] is undefined

So what does this error mean? it means the key (value of courseName variable) does not exists in courses object, so the first step of debugging this problem would be to look at :

available keys
key/property you attempt to use.

which can do by using breakpoint, or .log():

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

We see that you use dessert key (singular) while the available key is desserts (plural)

1 Like

Thanks! Took me a while to find the that was not plural… I feel ashamed. :sweat_smile: