I'm currently developing a program that randomly selects and prints a function from an array list. I am facing difficulties in getting the result to print correctly. Below is the snippet of code:
const hiddenElements = document.querySelectorAll(
".hidden",
".demo",
".hold",
".button",
"hold"
);
hiddenElements.forEach((el) => observer.observe(el));
var exerciseList = [
"10 push ups",
"5 pull ups",
"15 box squats",
"10 jump squats",
"8 single leg squats",
"20 mountain climbers",
"1 minute plank",
"20 resistance band pull-aparts",
"30 second bar hang",
"15 second hangboard",
"5 diamond push ups",
"5 military/wide push ups",
"15 lunges",
"1 minute skip rope",
"30 second wall sit",
];
var workoutElement = document.getElementById("workouts");
button.addEventListener("click", function () {
var randomIndex = Math.floor(Math.random() * Math.floor(exerciseList.length));
workoutElement.innerText = exerciseList[randomIndex];
console.log(workoutElement);
});