Issue with menu maker project

Hi,

I’m on the menu maker project and followed the youtube video but still getting an error in the code posted here: https://gist.github.com/9b6358e1a455f19a3ca59dd2a0d71401

The youtube vidoe link: https://www.youtube.com/watch?v=dfQlhjmb-P0&feature=youtu.be

Error:
/home/ccuser/workspace/learn-javascript-objects-meal-maker/app.js:38

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

TypeError: Cannot read property ‘push’ of undefined

Thanks
Jag

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:

Thanks

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.

2 Likes

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