June 21, 2026 @ 05:56
---
>[!Tip] Ternary Operator
>A **ternary operator** is a compact way to choose between 3 values based on a condition, usually written like:
>```js
>condition ? value_if_true : value_if_false
>```
For example, in JavaScript:
```js
let status = score >= 60 ? "pass : fail";
```
This is equivalent to `if...else` logic for a simple value choice, like this:
```js
let status;
if (score >= 60) {
status = "pass";
} else {
status = "fai;";
}
```
**NOTE**: **Go** does not have a ternary operator. You would use a normal `if` statement instead