Meal Maker price undefined

Hi there!
Somehow my price, in the end, is still “undefined” even though I assigned it to a value…
Do you have any idea where the mistake ist?

Here you can see the code:

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 meal is ${this._meal} for $${this.price}!`
      }else{
        return "Meal or price not set correctly!"
      }
  }
};

menu.meal = "pizza";
menu.price = 7;

console.log(menu.todaysSpecial);

and here is the outcome:

Today's meal is pizza for $undefined!

Try putting the underscore in front of price in $${this.price}!

Yeeessss it worked! Thanks a lot!!

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