Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

print random string from an array to screen in javascript

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 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #print #random #string #array #screen #javascript
ADD COMMENT
Topic
Name
3+3 =