Skip to content

Latest commit

 

History

History
35 lines (25 loc) · 627 Bytes

14.md

File metadata and controls

35 lines (25 loc) · 627 Bytes

if - else

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