Function shuffle

  • shuffling algorithm, Reordering arrays or strings

    Parameters

    • value: string

      arrays or strings

    • Optionalsize: number

      new array or string length

    Returns string

    • result
    const str = 'abcde'
    const arr = [1,2,3]

    shuffle(str)
    // cdbse

    shuffle(arr)
    // [3, 1, 2]

    shuffle(arr, 2)
    // [3, 2]

    5.4.0

  • shuffling algorithm, Reordering arrays or strings

    Type Parameters

    • T extends unknown[] = unknown[]

    Parameters

    • value: T

      arrays or strings

    • Optionalsize: number

      new array or string length

    Returns T

    • result
    const str = 'abcde'
    const arr = [1,2,3]

    shuffle(str)
    // cdbse

    shuffle(arr)
    // [3, 1, 2]

    shuffle(arr, 2)
    // [3, 2]

    5.4.0