Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this exercise, you'll develop a player-vs-computer game that tallies odd and even numbers until there's a winner. You should design your interface to look
In this exercise, you'll develop a player-vs-computer game that tallies odd and even numbers until there's a winner. You should design your interface to look similar to the image below (refer to the CSS and code used in the Reservation assignment to figure out the appropriate layout). Let's Play ODDS AND EVENS! -Rules The computer is even, you are odd (no offense) Each round, you and the computer "hold up" 1 to 5 fingers. The total number of fingers are tallied. Even totals go to the computer. Odd totals go to you. First to 50 wins. Play -This round You: 5 Computer: 2 -Totals - You: 16 Computer: 4 After the Play button is clicked, the user will see a series of prompts, like this: Enter a number between 1 and 5, or 999 to quit 999 OK Cancel The game ends when either the player or the computer reaches 50 or when the user enters 999 to quit. In either case, the application should display an appropriate message like: "You WIN!", "You lose :(", or You quit" in the span element to the right of the Play button. 1. You will need five functions in your JavaScript file. a. The $ function. b. The getRandomNumber function. C. A resetFields function that resets the text boxes and message area. d. The start of a playGame function. e. And an onload event handler that attaches the playGame function to the click event of the Play button. 2. Within the playGame function, use a while loop to get user entries until the player quits or either the player or computer has reached 50. Then, display the appropriate message to the right of the Play button. Within the while loop, consider using a break statement to end the loop if the player quits. 3. Within the playGame function, call the resetFields function whenever the fields need to be reset. 4. Be sure to have data validation to make sure the entry is a valid number from 0 through 5
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started