Project Meal Maker

I am currently struggling with the step 12 of the project Meal Maker.
Here is my code :

When I tried to add dishes using the menu.addDishToCourse(), it shows my an error message.
There was nothing before I tried adding the dishes.

Thanks for helping !

get _courses() {

There is the recursion that is resulting in this error. Read up on circular reference. for a closer understanding of the problem. It follows one will read up on MDN the basic nature of get and set and their vulnerability to recursion if not applied correctly.

get courses() {


It is within this code body we can drill into _courses.


Thanks for the quick reply. I made some change but there is now another error message :

This is my code :

Thanks a lot.

Here is your _courses object:

Here is your addDishToCourseMethod mentioned in the error message:

And here is where you call the method:

When you call the method, what arguments are passed? One of the arguments is passed to the parameter courseName which is used in the line of code throwing the error. Does your _courses object have a property with the name passed to courseName?

You have a second issue unrelated to the error here:

  addDishToCourse (courseName, dishName, dishPrice) {
    const dish = {
      name: this.courseName,
//          ^^^^ what does this refer to?
      price: this.dishPrice
//           ^^^^ also here
// this refers to the menu object. The menu object doesn't have properties named courseName or dishPrice
// when referring to the parameters of your method, simply use their names
// also, you're creating a dish object with a name property and a price property. Is courseName the parameter assigned to the value that you want to assign to?
    return this._courses[courseName].push(dish);
1 Like

Thanks, it does work now.

1 Like

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