time-to-botec/squiggle/node_modules/@stdlib/utils/if-else
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00
..
docs feat: add the node modules 2022-12-03 12:44:49 +00:00
lib feat: add the node modules 2022-12-03 12:44:49 +00:00
package.json feat: add the node modules 2022-12-03 12:44:49 +00:00
README.md feat: add the node modules 2022-12-03 12:44:49 +00:00

ifelse

If a condition is truthy, return x; otherwise, return y.

Usage

var ifelse = require( '@stdlib/utils/if-else' );

ifelse( bool, x, y )

If a condition is truthy, returns x; otherwise, returns y.

var z = ifelse( true, 1.0, -1.0 );
// returns 1.0

z = ifelse( false, 1.0, -1.0 );
// returns -1.0

Examples

var randu = require( '@stdlib/random/base/randu' );
var ifelse = require( '@stdlib/utils/if-else' );

var z;
var i;

for ( i = 0; i < 100; i++ ) {
    z = ifelse( randu() > 0.9, 'BOOP', 'beep' );
    console.log( z );
}