mardi 4 mai 2021

Find the error in "if else" statement, call function meal for Monday, Tuesday and Wednesday

let logDuties = [
"breakfast", "workout", "javascrpit" , "coffee"];

const logEntries = {
Monday : "Meditation",
Tuesday : "graffiti",
Wednesday : "Frittata",
logEntries : logDuties };

Meal plan for Wednesday should be vegan, keto and rest of the days/week should be protein, green.how do you call meal function for particular days? what's wrong with the code?

function meal (dayOfTheWeek) {
if (dayOfTheWeek === logEntries.Wednesday)
return meal = ["vegan" , "keto"];
} 
else (dayOfTheWeek !== logEntries.Wednesday)
return meal = ["Protien", "green"];

} }

Aucun commentaire:

Enregistrer un commentaire