function generateResults() {
    highscoresPage.style.display = "none";
    quizPage.style.display = "none";
    resultsPage.style.display = "block";

    var finalScore = correctAnswers * 20;
    score.textContent = finalScore;

    submitEL.addEventListener("click", (event)=> {
        event.preventDefault();
    
        var initialsEl = main.querySelector("#initials");
        var initials = initialsEl.value;

        // Validates that the user entered in something
        if (initials === ""){
            return;
        } else {
            var userInfo = {initials, finalScore};    
            var highscores = [];  
    
            if (!localStorage.getItem("highscores")){
                highscores.push(userInfo);
                localStorage.setItem("highscores", JSON.stringify(highscores));
            } else {
                var existingHighscores = localStorage.getItem("highscores");
    
                highscores = JSON.parse(existingHighscores);
                highscores.push(userInfo);
    
                localStorage.setItem("highscores", JSON.stringify(highscores));
            };
            
            generateHighscores();
        };
    });
}
// Generates the results page and form for adding to the highscores
Generates the results page and form for adding to the highscores
Generates the results page and form for adding to the highscores
function generateResults() {
    highscoresPage.style.display = "none";
    quizPage.style.display = "none";
    resultsPage.style.display = "block";
    var finalScore = correctAnswers * 20;
    score.textContent = finalScore;
    submitEL.addEventListener("click", (event)=> {
        event.preventDefault();
        var initialsEl = main.querySelector("#initials");
        var initials = initialsEl.value;
        if (initials === ""){
            return;
        } else {
            var userInfo = {initials, finalScore};    
            var highscores = [];  
            if (!localStorage.getItem("highscores")){
                highscores.push(userInfo);
                localStorage.setItem("highscores", JSON.stringify(highscores));
            } else {
                var existingHighscores = localStorage.getItem("highscores");
                highscores = JSON.parse(existingHighscores);
                highscores.push(userInfo);
                localStorage.setItem("highscores", JSON.stringify(highscores));
            };
            generateHighscores();
        };
    });
}
function generateResults ( ) { highscoresPage . style . display = "none" ; quizPage . style . display = "none" ; resultsPage . style . display = "block" ; var finalScore = correctAnswers * 20 ; score . textContent = finalScore ; submitEL . addEventListener ( "click" , ( event ) => { event . preventDefault ( ) ; var initialsEl = main . querySelector ( "#initials" ) ; var initials = initialsEl . value ; if ( initials === "" ) { return ; } else { var userInfo = { initials , finalScore } ; var highscores = [ ] ; if ( ! localStorage . getItem ( "highscores" ) ) { highscores . push ( userInfo ) ; localStorage . setItem ( "highscores" , JSON . stringify ( highscores ) ) ; } else { var existingHighscores = localStorage . getItem ( "highscores" ) ; highscores = JSON . parse ( existingHighscores ) ; highscores . push ( userInfo ) ; localStorage . setItem ( "highscores" , JSON . stringify ( highscores ) ) ; } ; generateHighscores ( ) ; } ; } ) ; }
Generates the results page and form for adding to the highscores
Generates the results page and form for adding to the highscores
// Validates that the user entered in something