---
title: ? (ternary)
slug: ternary
createdAt: 2021-09-14T17:53:00.000Z
---

Evaluates the truthiness of an expression, and returns the value of one of two expressions based on that outcome.

### Syntax

`condition ? ifTrue : ifFalse`

- `condition` - the conditional expression to be evaluated for truthiness.
- `ifTrue` - the expression to be evaluated if `condition` is found to be truthy.
- `ifFalse` - the expression to be evaluated if `condition` is not found to be truthy.

### Sample usage

`base * (tenure < 12 ? tenure / 12 : 1)` returns the prorated base salary of someone if they are under 12 months tenure, otherwise returns their base.&#x20;

### See also

- [?: (elvis)](docId\:X-HM1Bldw8aWd8-byRlZV)&#x20;
- [. (dot)](docId\:t8HBpyTpsANh8YfiZ4YJf)&#x20;
- [&& (and)](docId\:UVpXLLWGCPZRpr42E2NXm)&#x20;

