If, Else if and Else Statement

If Statement execute a block of code if a specified condition is true, else if execute when the first condition is false and want to test another condition and else statement execute if all condition is false.

Code Structure
var country = prompt("Where are you from?");
if(country === "UK"){
 alert("You are from Europe.");
} else if(country === "Australia"){
 alert("You are from Australia.");
} else {
 alert("You are from Asia.");
}

Share this

Related Posts