Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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 

 
PREVIOUS NEXT
Tagged: #pick #random #string #array #javascript
ADD COMMENT
Topic
Name
7+9 =