📌  相关文章
📜  在javascript代码示例中从数组中打印随机字符串到屏幕

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

代码示例4
pick random string from array javascriptJavascript By Joyous Jackal on Jun 14 2020
var groceries = [
'milk',
'coriander',
'cucumber',
'eggplant'
]
let mygroceries = groceries[Math.floor(Math.random() * groceries.length)]
console.log(mygroceries)//This gives you any string from groceries