Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A . Create an external JavaScript file called p4.js in your 111/p4 folder . B . Declare an object expression cardObject using the following code:

A. Create an external JavaScript file called p4.js in your 111/p4 folder.

B. Declare an object expression cardObject using the following code:

const cardObject = { /* TODO [C]: Add the following properties (remember to start properties with an underscore): - timer ID property used to stop timer, initialized to null, example: _intervalID: null, - initial counter property starting value - counter property that will count down to zero - cards array initialized using a string and the split() method - suits array initialized using a string and the split() method */ getRandomCard: function() { // TODO [H]: Return a random card value from the cards array // TODO [H]: If card is 0, then use 10 to account for actual image file  // Hint: Generate a random array index value for the cards array }, getRandomSuit: function() { // TODO [I]: Return a random suit value from the suits array  // Hint: Generate a random array index value for the suits array }, loadImages: function() { // TODO [J]: Update img element src attribute with a randomly generated card and suit image file name  // Hint: You will need to call getRandomCard() and getRandomSuit() to create image filename }, countDown: function() { // TODO [G]: Decrement and display count down value, and upon reaching 0 stop timer and display card image  // Hint: You will need to call displayCountdown(), stopCountDownTimer() and loadImages() }, displayCountDown: function() { // TODO [F]: Update countdown span element with current countdown value  // Hint: Get a reference to count down span and set the span textContent property with the counter }, startCountDownTimer: function(start) { // TODO [D]: Start timer, setting any appropriate object properties, with an interval of one second this._startCount = start; this._counter = this._startCount; this.displayCountDown(); this._intervalID = setInterval(this.countDown.bind(this), 1000); }, stopCountDownTimer: function() { // TODO [E]: Stop timer using object timer property  // Hint: Will need to call clearInterval() }, getRandomNumber: function(min, max) { // Generate a random integer between min (included) and max (excluded) let randomNum = Math.random() * (max - min) + min; return Math.floor(randomNum); } } const timedCard = Object.create(cardObject); timedCard.startCountDownTimer(5);

C. Implement the five object properties per instructions in the comments. (Please do this part)

D. Implement and test startCountDownTimer() method per comments. Note: The method code has already been provided.

E. Implement and test stopCountDownTimer() method per comments.

F. Implement and test displayCountDown() method per comments.

G. Implement and test countDown() method per comments.

H. Implement and test getRandomCard() method per comments.

I. Implement and test getRandomSuit() method per comments.

J. Implement and test loadImages() method per comments.

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

More Books

Students also viewed these Databases questions

Question

differentiate the function ( x + 1 ) / ( x ^ 3 + x - 6 )

Answered: 1 week ago