Randomly select an element from an array


let array = [...] // 数组
let item = array[Math.floor((Math.random()) * array.length)]
console.log(item) // 随机取的元素

Guess you like

Origin blog.csdn.net/qq_29517595/article/details/129820353