how to get a random element form a array code example
Example 1: pick a random element from an array javascript
var myArray = [
"Apples",
"Bananas",
"Pears"
];
var randomItem = myArray[Math.floor(Math.random()*myArray.length)];
Example 2: javascript return a random value from an array
const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
const randomMonth = months[Math.floor(Math.random() * months.length)];
console.log("random month =>", randomMonth);