Answers for "pick random string js from array"

1

pick random string from array javascript

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
Posted by: Guest on June-14-2020
0

randomly pick string from array

echo ['green', 'blue', 'red'][rand(0,2)];
Posted by: Guest on June-28-2021

Code answers related to "pick random string js from array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language