- 720p
- 540p
- 360p
- 0.50x
- 0.75x
- 1.00x
- 1.25x
- 1.50x
- 1.75x
- 2.00x
We hope you enjoyed this lesson.
Cool lesson, huh? Share it with your friends
About this lesson
Exercise files
Download this lesson’s related exercise files.
Conditional Statements58.9 KB Conditional Statements - Solution
59.1 KB
Quick reference
Conditional Statements
Conditional statements allow us to test against conditions.
When to use
Any time you want to test against a condition and take some action based on that condition, use a conditional statement.
Instructions
The main conditional statements are IF, IF/ELSE, and IF/ELSEIF.
An If Statement takes this form:
if (condition) {
// do something
}
And if/else statement takes this form:
if (condition) {
// do something
} else {
//do something else
}
An if/elseif statement takes this form:
if (condition) {
// do something
} elseif (condition 2) {
//do something
} else {
//do something else
}
Hints & tips
- The main conditional statements are If, If/Else, and If/Elseif
- Use our comparison operators and logic operators as the conditions
Lesson notes are only available for subscribers.