Issue with menu maker project


I’m on the menu maker project and followed the youtube video but still getting an error in the code posted here:

The youtube vidoe link:


  • return this._courses[courseName].push(dish);*
  •                                ^*

TypeError: Cannot read property ‘push’ of undefined


The good thing about errors is they tell us where things go wrong, so then the first step would be to check what the values are when your code is failing:

console.log(this._courses, courseName, dishName, dish)
return this._courses[courseName].push(dish);

by logging, we can gain more information why the code is failing.

well surprisingly that helped, as found I did not specify the dessert variable correctly :grinning:


1 Like

that is just the side-effect, the more important lesson when facing an error like this, is to inspect/log the values involved, which can help you narrow down the problem. Teaching yourself these steps is far more important then just getting to the solution in this one particular case.


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.