Meal maker issues

Hi there!

I finished the meal maker activity but I’m getting some error messages in the console.

I followed the video tutorial to try to repair my code, but the errors persist…

Could you help me with that?


you could start by logging information which might help you identify where the undefined comes from:

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

if we now get an undefined, we log the relevant information.

1 Like

cool, I found a few undefined!

Now you have to do the same step again, where do these undefined comes from?

you really need to think how you want to use getters and setters (if at all)

1 Like

Most things are observable by printing out what’s being done. Not getting the expected outcome? Print out what’s being done and compare to what you meant.
Similarly you can use printing while writing code to check things as you write them. Helpful both for seeing that it looks about right (it’s not proof but it’s something) and for deciding what to do next given what you’ve got so far.

1 Like

Ready, thank you both for your help!

The get and set code was not complete (now done!), although the issue that was quite confusing for me was in addDishToCourse.

I was returning the result directly to “_courses” instead of “get courses”.

Here the solution:

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