Else Statements
The else statement is used to execute code when the condition in the if statement is false. The syntax for an else statement is as follows:
if (condition) {
// code to be executed if condition is true
} else {
// code to be executed if condition is false
}
The else statement is optional. If the else statement is not present, and the condition in the if statement is false, then no code will be executed.
Here is an example of an if statement with an else statement:
Task
Run the above code and experiment with the code to get used to it.