Erorrs with object methods

Hello Guys i did the meal maker project but i still get some erorrs. I don know where they are, as i also looked up the video. Can you please take a look over and help me :slight_smile:
Thank you

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 = 8;

return this._meal === mealToCheck; 
// should be assignment instead of comparison
return this._meal = mealToCheck;

return this.price = priceToCheck;
// should be
return this._price = priceToCheck;
// otherwise you will recurse calling the price setter over and over

// Missing comma after the price setter
set price(priceToCheck) { 
},      <---------- Comma here

return `Today’s Special is ${this._meal} for &{this._price}!` ;
// should be
return `Today’s Special is ${this._meal} for ${this._price}!` ;
1 Like

Setters don’t need to return. The backing variable is set in object context.


You are correct.


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