You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

shuffle.js 269B

12345678910
  1. export const shuffle = (array) => {
  2. const newArray = [...array];
  3. newArray.reverse().forEach((item, index) => {
  4. const j = Math.floor(Math.random() * (index + 1));
  5. [newArray[index], newArray[j]] = [newArray[j], newArray[index]];
  6. });
  7. return newArray;
  8. };