A instrução if executa diferentes blocos de código com base nas condições.
```
if (condition) {
// Do something when `condition` is true
}
else {
// Do something when `condition` is false
}
```
Quando a `condition` é verdadeira, o código dentro da seção `if` executado, caso `else` executado. Às vezes você precisaria adicionar uma segunda condição. Para facilitar a leitura, você deve usar uma instrução `else if` vez de aninhar `if` .
```
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
}
```
Observe que o `else` e `else if` seções não forem necessárias, enquanto `if` for obrigatório.