Answers for "how to print a random string from an array in javascript"

4

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
2

js random string from array

const randomElement = array[Math.floor(Math.random() * array.length)];
Posted by: Guest on April-07-2020
0

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
Posted by: Guest on September-30-2020

Code answers related to "how to print a random string from an array in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language