kaven-basic - v6.0.0
    Preparing search index...

    Function GenerateRandomInt

    • Generates a random integer between the specified min and max values.

      Parameters

      • min: number

        The minimum integer value (inclusive).

      • max: number

        The maximum integer value (inclusive or exclusive based on maxExclusive).

      • maxExclusive: boolean = false

        If true, the max value is exclusive; otherwise, it is inclusive. Defaults to false.

      Returns number

      A random integer between min (inclusive) and max (exclusive if maxExclusive is true, inclusive otherwise).

      • If maxExclusive is true, the result is in the range [min, max).
      • If maxExclusive is false, the result is in the range [min, max].
      • Both min and max are rounded to the nearest integer using Math.ceil and Math.floor respectively.
      // Inclusive max
      const random1 = GenerateRandomInt(1, 10); // 1 <= random1 <= 10

      // Exclusive max
      const random2 = GenerateRandomInt(1, 10, true); // 1 <= random2 < 10

      4.0.0

      2021-12-12