In [[JavaScript]], conditions can be set for certain actions to be executed.
## If
```js
if (age < 27) {
// Action
}
```
## Else
`else` can be used after `if` to define what happens if the first condition is not met.
```js
if (flagEnabled) {
// Action if the flag is enabled
} else {
// Action if the flag is not enabled
}
```
## Else If
`else if` extends upon `else` by defining what happens if none of the previous conditions is met.
```js
if (randomNumber < 51) {
client = 'clientA'
} else if (randomNumber < 86) {
client = 'clientB'
} else {
client = 'clientC'
}
```
In the code above, `client` will be assigned the value of `clientC` only if `randomNumber` is greater than 85; i.e., only if the first two conditions are not met.
[[Requests by percentages in k6]] has a full example for this.