Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

b) Write the JavaScript codes based on the guidelines given below.[10 marks] In function startO: Declare all the variables used in this function. Ask how

image text in transcribed
image text in transcribed
image text in transcribed
b) Write the JavaScript codes based on the guidelines given below.[10 marks] In function startO: Declare all the variables used in this function. Ask how many times the user wants to roll the dice using a prompt box. Use a while loop to make sure that the number of rolls must be from 1 to 10 only. Ifother values are inserted, ask the user to re-enter the value. Ask the user which number to search for based on the numbers on the dice using a prompt box Use a while loop to make sure that the number that is searched for must be from 1 to 6 only. Ifother values are inserted, ask the user to re-enter the value o o o o o Continued. Next, call function display(.) and pass the number of times to roll and the number that is searched for. In function display.. Declare all the variables in this function. Use a while loop to get random numbers based on the number of rolls that is required. Keep track of how many of the random number matches the searched number o o o o Display the output as shown below SAMPLE OUTPUT .Ask the user how many times to roll the dice. This page says How many tinees would you like to throw the dice? 23 Cancel If the value entered is not from 1 to 10, ask the user to re-enter the value. This page says: Dice throws must be between 1 and 10 only OK Cancel Ask the use to enter the number to search. This page says What number would you like to search for? OK Cancel If the number entered is not from 1 to 6, ask the user to re-enter the number This page says: Number searched must be from 1to 6 only. OK Cancel If all values are entered correctly, the following output is displayed. Throw 1--> 1 Throw 2-2 Throw 3--> 3 Throw 4 4 Throw 5->5 Throw 6 5 You rolled the dice : 6 times. You searched for number:2 The system found numbe2e(s)

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

Students also viewed these Databases questions