mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
39 lines
722 B
Markdown
39 lines
722 B
Markdown
# Function ifElse
|
|
|
|
Execute a conditional expression.
|
|
|
|
|
|
## Syntax
|
|
|
|
```js
|
|
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
|
|
|
|
```js
|
|
var math = mathjs();
|
|
|
|
math.ifElse(true, 'yes', 'no'); // returns 'yes'
|
|
```
|
|
|
|
|
|
|
|
|
|
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|