else Statement
noun
say it: “ELSS STAYT-ment” /ɛls ˈsteɪtmənt/
The part after an if that runs when the if's condition is false: the "otherwise" path.
What does else Statement do in JavaScript?
else Statement — A branch that runs when its matching if condition is falsy.
if (stock > 0) {
status = "Available";
} else {
status = "Sold out";
}
In a sentence
- “I added an else statement so the page says "Sorry, we're closed" whenever isOpen is false.”
Level: Novice · More JavaScript terms at this level
Updated