Goal: Use if - else to run specific code blocks based on various conditions.
if (condition) {
// Code runs if the condition is true
} else {
// Code runs if the condition is false
}
The condition is usually the result of a comparison that returns true or false.
See you in workbook 3.2
Not only can we test only one condition, but also many conditions by embedding a series of else if (condition)
statements.
if (condition) {
// Code
} else if (condition) {
// Code
} else if (condition) {
// Code
} else {
// Code
}
See you in workbook 3.3 and 3.4