Can I use the clearInterval() function to stop a time display for a countdown clock? Is there a function available to reset the clock or do I have to create my own function?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Display the current time (the setInterval() method will execute the function once every 1 second, just like a digital watch). Use clearInterval() to stop time:
Definition and Usage
The clearInterval() method clears a timer set with the setInterval() method.
The ID value returned by setInterval() is used as the parameter for the clearInterval() method.
Note: To be able to use the clearInterval() method, you must use a global variable when creating the interval method:
myVar = setInterval("javascript function", milliseconds);
Then you will be able to stop the execution by calling the clearInterval() method.
Learn JavaScript here - https://hackr.io/tutorials/learn-javascript