Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026
The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.
You can provide a second part to the if statement: else.
You attach a statement that is going to be executed if the if condition is false:
if (true) {
//do something
} else {
//do something else
}
Since else accepts a statement, you can nest another if/else statement inside it:
if (a === true) {
//do something
} else if (b === true) {
//do something else
} else {
//fallback
} Lessons in this unit:
| 0: | Introduction |
| 1: | Comparison operators |
| 2: | `if` statements |
| 3: | ▶︎ How to use `else` |
| 4: | `switch` |
| 5: | The ternary operator |