mercredi 2 novembre 2016

Changing innerHTML back to nothing and High Score counter

My code is attached below. I was wondering what I need to do inside this gameReset() function to make the innerHTML remove the amount of clicks and go back to "Ammount of Clicks: ".

        var playerScore = document.getElementById("totalScore");
        click++;
        playerScore.innerHTML = "Amount of Clicks: " + click;

function gameReset() {


    }

I was also wondering why my High Score counter is not working?

<p id="totalScore">Amount of Clicks: </p>
<p id="highestScore">High Score: </p>


var highScore;




function checkWin() {
        var incorrect = 0;

        for (i = 0; i < 25; i++) {

            var check = document.getElementById("cell" + i).style.backgroundColor;  

            if (check == "yellow") {
                incorrect++;
            }
        }

        if (incorrect == 0) {
            alert("You Win!");
            checkHighScore();
            gameReset();


        }
    }



function checkHighScore() {
        if (!highScore || playerScore < highScore) {
            var theHighScore = document.getElementById("highestScore");
            highScore = playerScore;
            theHighScore.innerHTML = "High Score: " + highScore;
        }
    }

Aucun commentaire:

Enregistrer un commentaire