>[success] # 随机算法 ~~~ 1.将数组随机排序 ~~~ ~~~ function swap(array, a, b) { /* const temp = array[a]; array[a] = array[b]; array[b] = temp; */ [array[a], array[b]] = [array[b], array[a]]; } function shuffle(array) { let currentIndex = array.length; // 获取长度 while (currentIndex !== 0) { const randomIndex = Math.floor(Math.random() * currentIndex); currentIndex--; // 减少随机范围 swap(array, currentIndex, randomIndex); } return array; } ~~~