The if Statement part 2

The if Statement



This is another example of a false conditional statement.
var myNum1 = 7;
var myNum2 = 10;
if (myNum1 > myNum2) {
alert("JavaScript is easy to learn.");
}
Try It Yourself

As the condition evaluates to false, the alert statement is skipped and the program continues with the line after the if statement's closing curly brace.
Note that if is in lowercase letters. Uppercase letters (If or IF) will generate an error.
What happens if the tested condition is false?

The code does nothing and moves to the next section
The code in the braces is executed anyway
The code's execution will be stopped

Comments

Popular posts from this blog

Introducing object part 3

Comparison Operators part 2

Module 2