Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Slot Machine in JavaScript JavaScript assignments must only have canvas, canvas context and any HTML objects as global variables, everything else must be declared inside

Slot Machine in JavaScript

JavaScript assignments must only have canvas, canvas context and any HTML objects as global variables, everything else must be declared inside a class or a function using var.

Requirements:

1. Create a function, called spin, in the head section that takes no parameters but returns a random number between 0 and 6 inclusive.

2. Call this function three times and assign it to different variables.

3. Create another function, called evaluateGame, that takes three parameters and returns the a integer. (ALL WINS are evaluated from left to right 4,0,0 would be a losing game)

A) If there are three 0s for the random values win 14

B) If there are three of any other number win 7

C) If there are two 0s in the first and second spot then win 4.

D) If there are two of any other number in the first two spots win 2.

E) If there are is a 0 in the first spot then win 1.

F) The function will return the win score.

4. Create a function that takes in a single number. Based on that number you get to print a picture. (0 is cherry, the rest do not matter). (This is an HTML Image tab not canvas)

5. Underneath the three pictures print the winning score.

6. Put the above requirements in either a for loop or a while loop and do it three times. (Therefore, you should have three slot machines.)

7. Put a hyperlink at the bottom that links to the same page, make the text say spin. (You will re-load the page)

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_2

Step: 3

blur-text-image_3

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

Data Management Databases And Organizations

Authors: Richard T. Watson

2nd Edition

0471180742, 978-0471180746

More Books

Students explore these related Databases questions