Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils/if-else/docs/types/index.d"

Index

Functions

Functions

Export assignment ifelse

  • ifelse(bool: boolean, x: any, y: any): any
  • If a condition is truthy, returns x; otherwise, returns y.

    Parameters

    • bool: boolean

      condition

    • x: any

      value to return if a condition is truthy

    • y: any

      value to return if a condition is falsy

    Returns any

    either x or y

    Example

    var randu = require( `@stdlib/random/base/randu` );
    
    var z = ifelse( randu() > 0.5, 1.0, -1.0 );
    // returns <number>