const quizContainer = document.getElementById("quiz");
const resultsContainer = document.getElementById("results");
const submitButton = document.getElementById("submit");
// display quiz right away
buildQuiz();
const previousButton = document.getElementById("previous");
const nextButton = document.getElementById("next");
const slides = document.querySelectorAll(".slide");
let currentSlide = 0;
showSlide(0);
// on submit, show results
submitButton.addEventListener("click", showResults);
previousButton.addEventListener("click", showPreviousSlide);
nextButton.addEventListener("click", showNextSlide);This will (in short) execute your OnStart function if its present (so you can add it if you want).
If you prefer to go "HTML only", just specify the function you want to be executed.
For exemple:
<body onload="myFunc()">
<script>
function OnStart()
{
//your whole code here
}
</script>I haven't looked at the code in detail but isn't moving all his code into OnStart going to make his global variables local?
This probably applies to global functions too.