DEV Community

Discussion on: Shorten your if statements using the '&&' operator

Collapse
 
crivote profile image
crivote

Because is very limited. How would you add an else clause?

Collapse
 
toktoktwan profile image
Twan Mulder • Edited

Good question!

If the else clause if very simple, you could use a ternary operator instead.
So something like:

iAmHungry ? bakeAnEgg() : console.log("I'm not hungry!")