I'm trying to make this script work addEventListener. If you click on the button you should get a random text from the array. However, I’m not a javascript king. Please help me.
function GetValue()
{
var whys = new Array(
"why 1",
"why 2",
"why 3"
);
var random = whys[Math.floor(Math.random() * whys.length)];
var btn = document.getElementById("message");
btn.addEventListener("click", GetValue, false);
}
<span class="why_title" id="message">Ask Why!<br/>And Ask it Again<br/>And again</span>
<button class="why_btn" onclick="GetValue();">Ask Why Again!</button>