Shuffles the elements of an array randomly.
The function creates a new array and performs an in-place shuffle using the Fisher-Yates algorithm. This ensures that the shuffled array has a uniform random distribution of elements.
The input array to shuffle.
A new array with the elements shuffled randomly.
const shuffledArray = shuffleArray([1, 2, 3, 4, 5]);console.log(shuffledArray);// Output: A shuffled array, e.g., [4, 1, 3, 5, 2] (output will be random). Copy
const shuffledArray = shuffleArray([1, 2, 3, 4, 5]);console.log(shuffledArray);// Output: A shuffled array, e.g., [4, 1, 3, 5, 2] (output will be random).
Shuffles the elements of an array randomly.
The function creates a new array and performs an in-place shuffle using the Fisher-Yates algorithm. This ensures that the shuffled array has a uniform random distribution of elements.