Question: Javascript a) Create a global variable called lotto that is initialized to 0. b) when the generate number button is pressed, a function should check

Javascript

a) Create a global variable called lotto that is initialized to 0.

b) when the generate number button is pressed, a function should check to see if the number entered by the user is valid and if it is a winner

- The number is valid if it is a 2 digit number

- The number is a winner in the following three scenarios

- If it matches the lotto number in the exact order, the award is $10,000

- If both digits in the user input match both digits in the lottery number, but out of order, the award is $3,000

- If one digit in the user input matches a digit in the lottery number, the award is $1,000

- If no digits are matched, print the lotto number and "Please play again!"

Sample Output

 Javascript a) Create a global variable called lotto that is initialized
to 0. b) when the generate number button is pressed, a function

Welcome to the CPSC 1045 Lottery Application! Click this button to generate a random 2-digit lottery number: Enter your 2-digit lottery number here: Output here Enter your 2-digit lottery number here: The number was: 15. Exact match! You win $10000 Enter your 2-digit lottery number here: The number was: 45 . You match one digit! You win $1000 Enter your 2-digit lottery number here: The number was: 54. Matched both digits! You win $3000 Enter your 2-digit lottery number here: The number was 61 . Please play again

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!