print random string from an array to screen in 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
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
Also in JavaScript:
- how to check if user has installed pwa
- index of value in array
- How to find the max id in an array of objects in JavaScript
- Syntax Error: Thread Loader (Worker 0) .eslintrc.js: Environment key "es2021" is unknown at Array.forEach (<anonymous>)
- vuetify event handler
- devtools failed to load sourcemap when debugging react native
- update angular cli
- discord js check every x minutes
- device width javascript
- javascript convert date from mm/dd/yyyy to yyyymmdd
- arrow function javascript
- queryselector name attribute
- split the numbers js
- npm google map api react
- sort array based on another array
- how to send json data in fetch request body
- How do you wait for 5 seconds in JavaScript?
- how to add functionality inside js object
- jquery multiple selectors
- reqeuest body in hapijs
- click a link using jquery
- .env not working on react
- remove first element of array javascript
- are you sure you want to proceed click ok button javascript code