The if statement executes different blocks of code based on conditions.
```
if (condition) {
// Do something when `condition` is true
}
else {
// Do something when `condition` is false
}
```
When `condition` is true, code inside the `if` section executes, otherwise `else` executes. Sometimes you would need to add a second condition. For readability, you should use a `else if` rather than nesting `if` statements.
```
if (condition) {
// Do something if `condition` is true
}
else if (anotherCondition) {
// Do something if `anotherCondition` is ture
}
else {
// Do something if `condition` AND `anotherCondition` is false
}
```
Note that the `else` and `else if` sections are not required, while `if` is mandatory.