The if else Statement part 2

The if else Statement
24
2/2









The else Statement
The example below demonstrates the use of an if...else statement.
The above example says:
- If myNum1 is greater than myNum2, alert "This is my first condition";
- Else, alert "This is my second condition".
The browser will print out the second condition, as 7 is not greater than 10.
There is also another way to do this check using the ? operator: a > b ? alert(a) : alert(b).
Fill in the blanks to have a valid if...else statement:
var age = 25;
(age >= 18) {
alert("Allowed.");
}
{
alert("Not allowed.");
}
alert("Allowed.");
}
alert("Not allowed.");
}
Comments
Post a Comment