js select random from array random code example
Example 1: 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);
Example 2: js random string from array
const randomElement = array[Math.floor(Math.random() * array.length)];