Beginner Javascript – return function nightmare [closed]

I’m trying not to use the alert() function and instead create my own message. I have built a quiz, but when I test the error message, it works but won’t move on to the next question. I feel like it has something to do with the return statement but no matter where I put it, something else fails.
Could someone point me in the right direction? I’ve checked here, W3Schools, Shecodes, ChatGPT etc

if (submitButton) {
        submitButton.addEventListener("click", function () {
            var error = document.getElementById("error");
            
            if (!answerSelected && submitButton.innerText !== "Play Again?") {
                error.innerHTML = "<span style='color: red;'>" +
                    " Please choose an answer to proceed! ";
                // return;
            } else {
                //error = document.getElementById("error");
                error.style.display= "none";
            }

            if (submitButton.innerText === "Play Again?") {

                resetQuiz();
            } else {
                currentQuestion++;

                if (currentQuestion < questions.length) {
                    showQuestion();
                } else {
                    showResult();
                }
            }
        });
    }

I tried putting the return statement after the first else statement, but it just terminated early. I tried without any return statement and that just allows users to click “Next” without answering and no error message displays. I’m at a loss.