Making choices - conditionals

let cheese = "Cheddar";

if (cheese) {
  console.log("Yay! Cheese available for making cheese on toast.");
} else {
  console.log("No cheese on toast for you today.");
}

Can anyone help me out with this ?
I know the answer ("“Yay! Cheese available for making cheese on toast”)but can’t get it how ?

I think you need to give us a little more context here. For example, what should the answer be?

the answer is “Yay! Cheese available for making cheese on toast” but can’t get how?

your variable cheese has value of a string, which is a truthy value so when put in the conditional it behaves like the boolean true, and your if content executes

1 Like

What should be the condition such that the second option(“No cheese on toast for you today.”) will come as correct choice?

It’s the same condition, but the value of the variable would need to be different

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.