選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

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. };