Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created January 12, 2023 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/648a38ee0113aa66ff8d236a8b349247 to your computer and use it in GitHub Desktop.
Save codecademydev/648a38ee0113aa66ff8d236a8b349247 to your computer and use it in GitHub Desktop.
Codecademy export
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) {
console.log(`Today’s Special is ${this._meal} for $${this._price}!`);
} else {
console.log('Meal or price was not set correctly!');
}
}
};
menu.meal = 'Steak';
menu.price = 11;
console.log(menu.todaysSpecial);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment