< JavaScript < Reserved words
![](../../../I/m/Crystal_Clear_action_apply.png)
The code
The else keyword
The else keyword creates a clause inside the if statement. It is optional end executes only if all other if … else if blocks do not execute.
Examples
![](../../../I/m/Crystal_Clear_action_apply.png)
var result = 17;
if (result%2 == 0) {
console.log(result + " is even.");
} else if (result > 20) {
console.log(result + " is greater than 20.");
} else {
console.log(result + " is odd and not greater than 20.");
}
returns the following:
17 is odd and not greater than 20.
See also
This article is issued from
Wikibooks.
The text is licensed under Creative
Commons - Attribution - Sharealike.
Additional terms may apply for the media files.