知识点:Math.floor(),Math.random()向上取整和随机值
//输入[1,2,3,4,5]
//输出[3,2,1,4,5] 随机输出
function suiji(arr){
for(let i=arr.length-1;i>0;i--){
let targetIndex =Math.floor(Math.random()*i)
console.log(targetIndex)
let temp = arr[targetIndex]
arr[targetIndex] = arr[i]
arr[i] = temp
}
console.log(arr)
}
suiji([1,2,3,4,5])