Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RandomBoolean

Random generator for boolean values.

Example

let value1 = RandomBoolean.nextBoolean();    // Possible result: true
let value2 = RandomBoolean.chance(1,3);      // Possible result: false

Hierarchy

  • RandomBoolean

Index

Methods

Static chance

  • chance(chance: number, maxChances: number): boolean
  • Calculates "chance" out of "max chances". Example: 1 chance out of 3 chances (or 33.3%)

    Parameters

    • chance: number

      a chance proportional to maxChances.

    • maxChances: number

      a maximum number of chances

    Returns boolean

Static nextBoolean

  • nextBoolean(): boolean
  • Generates a random boolean value.

    Returns boolean

    a random boolean.

Generated using TypeDoc