10 lines
280 B
JavaScript
10 lines
280 B
JavaScript
export const shuffleArray = (array) => {
|
|
const shuffled = [...array];
|
|
for (let i = shuffled.length - 1; i > 0; i--) {
|
|
let j = Math.floor(Math.random() * (i + 1));
|
|
let temp = shuffled[i];
|
|
shuffled[i] = shuffled[j];
|
|
shuffled[j] = temp;
|
|
}
|
|
return shuffled;
|
|
};
|