Meal Maker Error


Wondering if anyone can help me figure out why my code doesn’t seem to work? I seem to be getting a syntax error in this part but cannot figure out if there’s anything wrong there or in the rest of my code somewhere? Do getters always need to return something as well?

Here’s the link to the rest of the code. Many thanks.

Hey there!

The error is pretty much on the money…

In your menu object, you’ve defined the class method addDishToCourse as .addDishToCourse().

You don’t need the leading ., which is what the error is complaining about. :slight_smile:

The dot when you call a method on an object is notation for looking up an attribute of an object:

let x = { a: 3 }
a.x  // 3

Once you have a method, you would likely call it


Calling something is done with the call operator which accepts a thing to call and arguments to send. This is no different from other operators, like +, they too accept values as input and produce some output, same as calling something.

Thank you both, this has made things more clear to me. I also seem to have made the same mistake elsewhere in the code too. However, now I am getting a syntax error in a different part. I have a feeling that perhaps I have misplaced a comma or semicolon somewhere in the code as a few of these errors have come up now and I seem to have been able to fix all of them apart from this particular one?

Posting a link to my code again with the few small changes I’ve made.

You can comment things out to eliminate possible causes, and if you run the code after each change you know it’ll be the last thing you wrote.

Thanks, finally got it to work now.!

1 Like

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