Java Reference
In-Depth Information
Figure 3.7. Adding age verification
else Statements
The else keyword can be used to add an extra block of code to run if the condition is
false. An i f ... else statement looks like this:
if (condition) {
code to run if condition is true
} else {
code to run if condition isn't true
As an example, we can test if a number is even or odd using the following code:
n = 12;
if (n%2 === 0) {
console.log("n is an even number");
} else {
Search WWH ::

Custom Search