The if else if else Statement part 2
else if
The final else block will be executed when none of the conditions is true.
Let's change the value of the course variablein our previous example.
The result:
You can write as many else if statements as you need.
Fill in the blanks to create a valid if...else...if statement:
var status = 1;
var msg;
(status == 1) {
msg = "Online";
}
(status == 2) {
msg = "Away";
}
else {
msg = "Offline";
}
var msg;
msg = "Online";
}
msg = "Away";
}
else {
msg = "Offline";
}
Comments
Post a Comment