Namespace
The type of elements in the array.
The array to be shuffled.
A new array with the elements randomly shuffled.
const numbers = [1, 2, 3, 4, 5];
const shuffledNumbers = shuffleArray(numbers);
console.log(shuffledNumbers); // Output: [3, 5, 1, 2, 4] (randomly shuffled)
const names = ['Alice', 'Bob', 'Charlie', 'David'];
const shuffledNames = shuffleArray(names);
console.log(shuffledNames); // Output: ['Bob', 'Charlie', 'Alice', 'David'] (randomly shuffled)
Generated using TypeDoc
ArrayUtils
Shuffles the elements of an array randomly.