HTML and CSS Reference
In-Depth Information
Figure 11-40
Kiddergarden guessing game page
You will be provided with a function named checkEndGame() that displays an alert
box telling the user whether he or she has won the game by guessing the number within
the allotted number of guesses, or has lost by failing to guess the correct number. The rest
of the code is left for you to complete.
Complete the following:
1. Use your text editor to open the guesstxt.htm file from the tutorial.11\case3 folder
included with your Data Files. Enter your name and the date in the comment section
of the file and save it as guess.htm . Take some time to study the content and structure
of the document, including the elements within the guessform web form.
2. Within the script element, declare the following four global variables: lowest ,
size , randNum , and guess . The lowest variable will be used to store the low-
est possible random integer in the guessing game. The size variable will store the
number of random integers in the game. The randNum variable will store the random
number generated by the Web page. The guess variable will store the user's current
guess. Set the initial values of the lowest and size variables to 1 and 500 , respec-
tively. Do not set initial values for the randNum and guess variables.
3. Below the four variable declarations you just created, insert the generateRandom()
function. The function, which will be used to generate a random number, has no
parameters. It should contain a single statement to set the value of the randNum vari-
able to a random integer between the values of the lowest and size variables. (Hint:
Use the code describing how to generate random integers presented in the tutorial to
aid you in writing this function.)
Search WWH ::




Custom Search