Function randomChoices

  • Generate new array by randomly picking items from provided array

    Type Parameters

    • T

    Parameters

    • array: readonly T[]
    • length: number

    Returns T[]

    Example

    randomChoices([1, 2], 3)
    // [2, 2, 1]