J
jar13861
Create a game in a 3x3 HTML table that works as follows:
* The goal of the game is to beat the computer by scoring more
points than the computer.
* The game starts when a hidden random number between 1 and 9 is
placed in each cell.
* The user and computer take turns by "clicking" on table cells.
When a cell is "clicked" by the user, the user scores the number of
hidden points in the cell. When the computer takes a turn, it "clicks
on" a random cell that has not been clicked yet and adds the hidden
points in the clicked cell to its scor
* The user always goes first, so they should have a better chance
of winning since they will get 5 turns and the computer 4 turns.
* The user wins if they score more points than the computer. The
computer wins if it scores more than the user.
Hints:
* Have your script first generate a set of random numbers from 1- 9
and place them randomly in an array. The numbers in the array will
need to be unique, so you will need a loop to go through and check that
each new random number has not already been used.
* Use the ONCLICK="clicked(cellNum)" in each cell(TD tag) to call
the a function called clicked(cellNum), passing in the cell
number(0,1,2,...,9) as the parameter. That way, when the function
named "clicked()" gets cellNum it will know which cell was clicked and
perform scoring based on that.
* Use a P or DIV tags to hold the scores for the user and computer.
Please help out anyway you can. I know I'm new, but I really really
need help.
* The goal of the game is to beat the computer by scoring more
points than the computer.
* The game starts when a hidden random number between 1 and 9 is
placed in each cell.
* The user and computer take turns by "clicking" on table cells.
When a cell is "clicked" by the user, the user scores the number of
hidden points in the cell. When the computer takes a turn, it "clicks
on" a random cell that has not been clicked yet and adds the hidden
points in the clicked cell to its scor
* The user always goes first, so they should have a better chance
of winning since they will get 5 turns and the computer 4 turns.
* The user wins if they score more points than the computer. The
computer wins if it scores more than the user.
Hints:
* Have your script first generate a set of random numbers from 1- 9
and place them randomly in an array. The numbers in the array will
need to be unique, so you will need a loop to go through and check that
each new random number has not already been used.
* Use the ONCLICK="clicked(cellNum)" in each cell(TD tag) to call
the a function called clicked(cellNum), passing in the cell
number(0,1,2,...,9) as the parameter. That way, when the function
named "clicked()" gets cellNum it will know which cell was clicked and
perform scoring based on that.
* Use a P or DIV tags to hold the scores for the user and computer.
Please help out anyway you can. I know I'm new, but I really really
need help.