Question: 17. Write a JavaScript function that gives a user 3 chances to guess the value of a randomly-generated number (in the range 1 - 9).

17. Write a JavaScript function that gives a user 3 chances to guess the value of a randomly-generated number (in the range 1 - 9). The user enters his/her guesses via a prompt box which has the text What is the number?

If the user guess is wrong, an alert box outputs Guess N is wrong, otherwise, an alert box outputs Correct and then the program exits.

Use the starter code given below.

var randomNumber;

var guess;

// Assume a random number has been generated and stored in the variable randomNumber

// Input the users guess into the variable guess

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!