I have the code as below, but can't get it work. It should return 1 value from the myArray, but it returns "undefined". What's the problem?
HTML
<div id="quote"></div>
JavaScript
var myArray = ['January', 'February', 'March'];
var rand = myArray[Math.floor(Math.random() * myArray.length)];
function showquote(){
document.getElementById('quote').innerHTML = myArray[rand];
}
showquote();
JSFiddle can be found here.
document.getElementById('quote').innerHTML = rand;console.log(rand)