I had to watch the video to get unstuck. I have it just like she does, and I get “Meal or price was not set correctly!”. Under the object, she has it as _menu & _price, I thought this was an error on her part and she would later change it. I have it as _meal and _price. She never changed it. I try it both ways and I still get the incorrect return message. I also have the … error (not red lines) at the setters for meal and price.
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 Todays Special is ${this._meal} for $${this._price}!
} else {
return Meal or price was not set correctly!
}
}
};
menu.meal = “Soup”;
menu.price = 2;
console.log(menu.todaysSpecial);
// You wrote:
if (this._meal && this.price)
// It should be:
if (this._meal && this._price)
// Also instead of space
_meal: ' ',
// should be empty string
_meal: '',
I am having the same issue but in my terminal its telling me Meal and price was not set correctly !.
I cant seem to find the problem
// create object
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 Todays meal is ${this._meal} for $${this._price}!;
} else {
return “Meal or price was not set correctly!”;
}
},
};
//Add Setter Methods step 5 to step 8
/*
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);
}
},
};
menu.meal = 9
menu.price = “pizza”
console.log(menu)
*/
//Add a Getter Method step 9 to step 11
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!’
}
},
};