in this section, we will build a timer to add to the Sudoku puzzle page, and will progress in three stages:
The behavior of the timer is to increment the number of seconds in an Hours:Minutes:Seconds format. A pause button will pause the timer, and change the label of the Pause button to Start; Pushing the Start button will resume the timer, and change the button text back to Pause
- startTimer executes at the start of the program and calls function advanceTimer
- advanceTimer advances the elapsedTime value if the timerRunning variable is True, and sets the HTML to display the formatted time
- formatTime returns a string representing the seconds in a HH:MM:SS format
- toggleTimer toggles the timerRunning boolean variable between True and False, and toggles the button label.
The program allows an initial number of seconds (non-zero) to be set. We will need this so we can save the puzzle, along with the elapsed time, and resume the timer when you re-launch the web-app.
the onclick event will execute a function upon clicking on that control