Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
56 lines (40 loc) · 935 Bytes

File metadata and controls

56 lines (40 loc) · 935 Bytes
Copy raw file
Download raw file
Edit and raw actions

Else

There is also an else clause that will be applied when the first condition isn’t true. This is very powerful if you want to react to any value, but single out one in particular for special treatment:

var umbrellaMandatory;

if(country === 'England'){
    umbrellaMandatory = true;
} else {
    umbrellaMandatory = false;
}

The else clause can be joined with another if. Lets remake the example from the previous article:

if(country === 'England') {
    ...
} else if(country === 'France') {
    ...
} else if(country === 'Germany') {
    ...
}

Fill up the value of name to validate the else condition.

var name =

if (name === "John") {

} else if (name === "Aaron") {
    // Valid this condition
}
var name = "Aaron";

if (name === "John") {

} else if (name === "Aaron") {
    // Valid this condition
}
assert(name === "Aaron");

Morty Proxy This is a proxified and sanitized view of the page, visit original site.