common-stuff
    Preparing search index...

    Function randomChoice

    • Returns a random element from the array or undefined if the array is empty.

      Type Parameters

      • T

      Parameters

      • array: readonly T[]

      Returns undefined | T

      randomChoice([1, 2, 3, 4, 5])
      // 2