📌  相关文章
📜  数组javascript代码示例中的随机项

📅  最后修改于: 2022-03-11 15:03:08.759000             🧑  作者: Mango

代码示例6
function RandomItemFromArray(myArray) {
    return myArray[Math.floor(Math.random() * myArray.length)]
}

var fruit = [ "Apples", "Bananas", "Pears", ];

let fruitSample = RandomItemFromArray(fruit)