➢Use the if statement to specify a block of JavaScript code to be executed if a condition is true.
EXAMPLE:
if (hour < 18) {
greeting = "Good day";
}
➢Use the else statement to specify a block of code to be executed if the condition is false.
EXAMPLE:
if (hour < 18) {
greeting = "Good day";
} else {
greeting = "Good evening";
}
➢Use the else if statement to specify a new condition if the first condition is false.
EXAMPLE:
if (hour < 10) {
greeting = "Good morning";
} else if (hour < 20) {
greeting = "Good day";
} else {
greeting = "Good evening";
}