I’m completing the Meal Maker Project. I can’t seem to understand why I continue to get “Meal or price was not set correctly!”. Can anyone help me understand what’s wrong with my code? I’m supposed to be getting Today’s Special is ${this._meal} for $${this._price}`.
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 === true) {
return Today's Special is ${this._meal} for $${this._price};
} else {
return “Meal or price was not set correctly!”;
}
},
};
let myArray = ["abc", "", 5, 0, true, false];
for (const element of myArray) {
console.log(`Element: ${element}`);
if (element) {
console.log("This element is truthy.");
}
if (element == true) {
console.log("This element is the boolean true.");
}
console.log("\n");
}
Have a look at the output and think about why each console.log statement is being printed or not printed.
// "abc" is truthy but not equal to true.
"Element: abc"
"This element is truthy."
// The empty string "" is neither truthy nor equal to true.
"Element: "
// 5 is truthy but not equal to true.
"Element: 5"
"This element is truthy."
// 0 is neither truthy nor equal to true.
"Element: 0"
// The boolean true is both truthy and equal to true.
"Element: true"
"This element is truthy."
"This element is the boolean true."
// The boolean false is neither truthy nor equal to true.
"Element: false"