Question: 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

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!