Setters not working for Meal Maker Project

I just completed the Meal Maker project from Intro to JavaScript. I can’t figure out why the setters aren’t working correctly. I’ve looked at videos and examples, but I seem to have written my code the same way. Any help is appreciated!

const menu = {
  _meal: " ",
  _price: 0,

  set meal(mealToCheck) {
    if (typeof mealToCheck === "string") {
      return (this._meal = mealToCheck);

  set price(priceToCheck) {
    if (typeof priceToCheck === "number") {
      return (this._price = priceToCheck);

  get todaysSpecial() {
    if (this._meal && this._price) {
      return `Today's Special is ${this._meal} for $${this._price}!`;
    } else {
      return "Meal or price was not set correctly!";

menu._meal = 'pizza';
menu._price = 12;

You aren’t actually using your setters at the bottom of your code there. menu._meal and menu._price are accessing the properties directly. You did however use the getter properly in the following line.


Got it. Thank you! I appreciate it!

1 Like