Skip to content

Latest commit

 

History

History
56 lines (40 loc) · 942 Bytes

else.md

File metadata and controls

56 lines (40 loc) · 942 Bytes

Else

There is also an else clause that will be applied every time 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 join 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");