Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

add a constructor function for the timer object containing two parameters named min and sec . Set the timer.minutes property equal to min, the timer.seconds

add a constructor function for the timer object containing two parameters named min and sec. Set the timer.minutes property equal to min, the timer.seconds property equal to sec, and the timer.timeID property equal to null.
Directly below the timer() constructor function, add the runPause() method to the timer object class prototype. The runPause() method has three parameters named timer, minBox, and secBox. Within the anonymous function for the runPause() method add the tasks described in Steps 5 through 6.
Insert an if else statement testing whether timer.timedID is truthy (has a value). If it does, you will pause the timer by applying the window.clearInterval() method using timer.timeID as the parameter value; set timer.timeID equal to null. Otherwise, run the window.setInterval() method to start the timer, running the countdown() function every 1000 milliseconds; store the id of the setInterval() method in the timer.timeID property.
Add the countdown() function that updates the timer every second. Within the function, add an if else statement that does the following:
If timer.seconds is greater than 0, decrease the value of timer.seconds by 1.
Else, if timer.minutes is greater than 0, decrease the value of timer.minutes by 1 and set the value of timer.seconds to 59.
Else the timer has reached 0:0; stop the timer by running the window.clearInterval() method with timer.timeID as the parameter value and then set the value of timer.timeID to null.
After the if else statement, write the value of timer.minutes to minBox.value and timer.seconds to secBox.value
Scroll to the bottom of the file. Declare an instance of the timer object and name it myTimer using minBox.value and secBox.value as the parameter values for the initial value of the timer.
Create an onchange event handler for minBox that sets myTimer.minutes to minBox.value. Create an onchange event handler for secBox that sets myTimer.seconds to secBox.value.
Create an onclick event handler for the runPauseTimer button that runs an anonymous function that applies the runPause() method to myTimer using myTimer, minBox, and secBox as the parameter values.

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

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

25.0 m C B A 52.0 m 65.0 m

Answered: 1 week ago

Question

13-4 What are alternative methods for building information systems?

Answered: 1 week ago

Question

13-1 How does building new systems produce organizational change?

Answered: 1 week ago