Need help with my pomodoro clock (Resuming counting)

Need help with my pomodoro clock (Resuming counting)


To be honest Pomodoro Project is quite challenging for me. My code is very sloppy as i’m beginner, so I could not figure out how to implement countdown so i copied the whole function from stackoverflow. Now i cannot understand how to resume countdown after i have paused it. Whenever i click start after pausing it counts down from the beginning. Please help me!
My Code


When you click start, this code is executed :

time = 60 * defaultSession;
display = document.querySelector('.timer-frame');
startTimer(time, display);

So, the timer starts again with the defaultSession time, which is 60 seconds * 25 minutes.

You need to keep track of the current time, and make the timer start on the current time, whenever you click on start.


That is the issue that i do not know how to do that


use setInterval and clearInterval alternatively. Something like this

$("#yourButton").on("click", function() {
if (stopFlag == false) {
     interID = setInterval(ReduceCountAndShowFunction, 1000);
     stopFlag = true;
   } else {
     stopFlag = false;


Thanks i’m going to try it!