given this function
function isTastyCheese(cheeseName: string) {
const TastyCheeses = ['camembert', 'maroilles']
if (TastyCheeses.includes(cheeseName)) {
return 'yes so tasty'
}
return undefined
}
I'd like to do something like this:
const answerCamembert = isTastyCheese('camembert') ? the_returned_value : 'no taste like sh*t'
const answerCantal = isTastyCheese('cantal') ? the_returned_value : 'no taste like sh*t'
console.log(answerCamembert)
>>> 'yes so tasty'
console.log(answerCantal)
>>> 'no taste like sh*t'
How do i use ternary operator to do this concisely?
PS: Obsviously the function presented here is very wrong but changing it shouldn't be part of the solution