-
-
Save codecademydev/648a38ee0113aa66ff8d236a8b349247 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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