Conditionally executes a group of statements, depending on the value of an expression.
Syntaxif ( condition1 ) {
statement1
} else if ( condition2 ) {
statement2
} else {
statement3
}
The following code shows how to use if , if else , and else.
It is good practice to enclose statement1 and statement2 in braces ({}) for clarity and to avoid inadvertent errors.
var z = 3;
if (x == 5) {
z = 10;
}
else if (x == 10) {
z = 15;
}
else {
z = 20;
}
See also Other articles
Attributions
Microsoft Developer Network: Article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4