HTML and CSS Reference
In-Depth Information
This variable holds the number of times the player has pressed a letter. The lower
the number, the better he has done in the game.
The content of this variable is displayed to give the user instructions on how to play.
This array holds one of each letter of the alphabet. We will use this array to both
randomly choose a secret letter for the game, and to figure out the relative position
of the letter in the alphabet.
This variable holds the current date. It is displayed on the screen but has no other
This variable holds the current game's secret letter that needs to be guessed.
This variable holds the text “Higher” or “Lower” depending on where the last
guessed letter is in relation to the secret letter. If the secret letter is closer to “a,”
we give the “Lower” instruction. If the letter is closer to “z,” we give the “Higher”
This array holds the current set of letters the player has guessed already. We will
print this list on the screen to help the player remember what letters he has already
This variable is set to false until the player wins. We will use this to know when
to put the “You Win” message on the screen, and to keep the player from guessing
after he has won.
Here is the code:
var guesses = 0;
var message = "Guess The Letter From a (lower) to z (higher)";
var letters = [
var today = new Date();
var letterToGuess = "";
var higherOrLower = "";
var lettersGuessed;
var gameOver = false;
Search WWH ::

Custom Search