Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Since we haven t done much using JavaScript in a browser yet, your first assignment will be to implement a basic Hi - Lo guessing

Since we havent done much using JavaScript in a browser yet, your first assignment will be to implement a basic Hi-Lo guessing game. This is an assignment I completed when I took CSC 171 and assign in other classes when introducing a different language since it does a good job illustrating several basic concepts. The game should proceed as follows:
When the user calls the run function (from the console we have been using in class) the game should begin.
The game will pick a random number between 1 and 100 inclusive and prompt the user for their guess (the prompt should be done using the browser dialogue box we talked about)
The game will then tell the user if their guess was too high, too low, or correct
If the guess was too low, the game will say the guess was too low and prompt the user for another guess
If the guess was too high, the game will say the guess was too high and prompt the user for another guess
If the guess was correct, the game will say the user guessed correctly and ask the user if they want to play again
The user should be allowed to quit at any time by typing quit at the prompt
If the user quits, the game should end immediately. That is, it should not prompt for more guesses and should not ask if the user wants to play again.
During each game, the game should keep track of user guesses and report a history of all guesses for that game when the user guesses correctly or when the user decides to quit.
The game also needs to keep track of the total guesses the user takes during that game and report the total guesses when the user guesses correctly or decides to quit.
If the user has played multiple games, your game should also report the average guesses it took the user to get the correct guess for all the games the user has played so far.
All output can either be printed to the console, included in the text for the prompt for the user, or both. It is up to you as long as the information is reported.
Make sure you break your program into appropriate functions (no more than 20 lines per function) and comment your code appropriately. To accomplish this assignment, you likely need one more piece of information:
To include JavaScript in an HTML document, you use script tags. You can type JavaScript directly within script tags or place JavaScript in a separate file. You can do that by creating a file with a .js extension (for example, hello.js) and include it in an HTML document with . Note that the closing script tag is required even if the tags have no content.
The script tags can appear anywhere on your HTML document. The browser will pause rendering the page to run any JavaScript it encounters. Traditionally, JavaScript is placed either within the head tags or at the bottom of the body section.
Grading will be done as follows:
20 points for a program that works exactly as described above
5 points for having good comments throughout your code
5 points for good programming style (functions, variable names, semicolons, using let,...)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions