mirror of
https://github.com/josdejong/mathjs.git
synced 2025-12-08 19:46:04 +00:00
722 B
722 B
Function ifElse
Execute a conditional expression.
Syntax
math.ifElse(condition, trueExpr, falseExpr)
Parameters
| Parameter | Type | Description |
|---|---|---|
condition |
Number | Boolean | String | Complex | BigNumber | Unit | The conditional expression |
trueExpr |
* | The true expression |
falseExpr |
* | The false expression |
Returns
| Type | Description |
|---|
- | The evaluated return expression
Examples
var math = mathjs();
math.ifElse(true, 'yes', 'no'); // returns 'yes'