ixfx
    Preparing search index...

    Function integer

    • Returns a random integer between max (exclusive) and 0 (inclusive) Use integerSource to return a function instead.

      integer(10);  // Random number 0-9
      

      If a negative value is given, this is assumed to be the minimum (inclusive), with 0 as the max (inclusive)

      integer(-5);  // Random number from -5 to 0
      

      Specify options for a custom minimum or source of random:

      integer({ max: 5,  min: 10 });  // Random number 4-10
      integer({ max: -5, min: -10 }); // Random number from -10 to -6
      integer({ max: 10, source: Math.random }); // Random number between 0-9, with custom source of random

      Throws an error if max & min are equal

      Parameters

      • maxOrOptions: number | Readonly<{ max: number; min?: number; source?: RandomSource }>

        Max value (exclusive), or set of options

      Returns number

      Random integer