Guessing Game

by wooozy

HTML

<font size="3" color="blue">Welcome to the Guessing game</font>
Your Guess: <input type='text' id='guess'>


<button id="checkBtn">Check</button>

CSS

http://stackoverflow.com/questions/25856960/keeping-a-running-list-on-a-page-using-javascript

JavaScript

document.getElementById('checkBtn').onclick = function (){
    var guess = document.getElementById('guess').value;
    checkGuess(guess);
    counter++;

    if(counter == maxGuesses) {
        alert("Game Over");
        document.getElementById("checkBtn").disabled = true;
    }
}


function checkGuess(guess){
    if (guess == rannum){ //if the value of playerguess is the same as rannum then the player wins
        alert("You win!");
        document.getElementById("checkBtn").disabled = true;
    }
    if (guess > rannum){ //if the player's guess is higher than the random number alert too high
        alert("Too high!");
        document.getElementById("guess").value='';
    }

    else if (guess < rannum){ //if the player's guess is lower than the random number alert too low
    alert("Too low!");
         document.getElementById("guess").value='';
     }