Answered step by step
Verified Expert Solution
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 through
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 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 decrease the value of timer.seconds by
Else, if timer.minutes is greater than decrease the value of timer.minutes by and set the value of timer.seconds to
Else the timer has reached :; 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 secBoxvalue
Scroll to the bottom of the file. Declare an instance of the timer object and name it myTimer using minBox.value and secBoxvalue 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 secBoxvalue.
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started