• Randomizes the order of elements in an array using the Fisher-Yates shuffle algorithm.

    Type Parameters

    • T

    Parameters

    • array: T[]

      The array to shuffle.

    Returns T[]

    A new array with the same elements in random order.

    Example

    shuffleArray([1, 2, 3, 4, 5]); // Returns: [3, 1, 5, 2, 4] (random order)
    shuffleArray(['a', 'b', 'c']); // Returns: ['c', 'a', 'b'] (random order)
    shuffleArray([]); // Returns: []

Generated using TypeDoc