Utilizor
Contact Us

If...Else

Handling false conditions.

If...Else

Use the else statement to specify a block of code to be executed if the condition is false.

if (condition) { // block of code to be executed if the condition is true } else { // block of code to be executed if the condition is false }

Example

if (hour < 18) {
  greeting = "Good day";
} else {
  greeting = "Good evening";
}