I’m trying to call a function that I got randomly from an array. Here is the link:https://codepen.io/Dims09/pen/poRrKWP
Right now I have the following code: JS
const areoT = document.getElementById("for");
function getValue() {
var randoRandit = [na(), na2(), na3(), na4()];
var rand = randoRandit[Math.floor(Math.random() * randoRandit.length)];
// alert(rand)
// document.getElementById("for").innerHTML=rand;
}
HTML
<div id="for"></div>
<button id="J?2e" onclick="getValue()">CF</button>
What Im wondering Is how to call it once gotten random item.
I’ve tried eval(), window[](), and even rand() .
Can anyone help me?
yourbtnid.addEventListener("click", evt => getValue(evt));, and modern HTML basics: don't put question marks inidattributes. Whatever taught you HTML and Js is a bad tutorial/site/book, and even for your own skill/sanity you want to revisit modern JS and HTML by hitting up some properly modern tutorials (e.g. written in the last year specific to HTML5 and ES6, but ideally ES2020)