Pomodoro Clock: Unable to Start the 2nd Timer after the 1st One Finishes

Hey,

I need help with the pomodoro clock, I want to create two countdown timers, the first one for the session time and the second one (which starts immediately after the 1st one finishes) for the break time, using setInterval or setTimeout.

I wrote a code to do it, but it’s not working as mentioned above (i.e. the 2nd (break) timer doesn’t start after the 1st one is done): https://jsfiddle.net/ovbmf7dp/ .

var b_countDown but you are using b_countdown
when i changed this and console.log … both timers are running at the same time
when they hit 0 more problems kick in then … but seeing as both timers are running at same time need that sorted before you move on.
will have a look at mine and see if i can offer any suggestions

edit ok managed to stop both your timers by changing a little first you named both of them they same … timeout_id so changed one too timeout_2d then to stop them …
if(s_countdown === 0) clearInterval(timeout_id); // you had clearSession … for one
}, 1000);
if(b_countDown === 0) clearInterval(timeout_2d);
}, 1000);
i changed highlighted all occurances from counddown

now you need to figure out how to run one finish that and run second

In mine i used one setInterval … when it reached 0 i removed a class from the element displaying the time and added this class to the element displaying the break … this way the setinterval never stopped it just check if display is 0
when break reached 0 it removed class from element

Thank you.

Fixed the typo. :blush:

Sorry about the two timers running at the same time. I was testing something and forgot to remove it. Fixed that too.

But I still have the original problem.

i was editing my post when you posted so you might not have seen this

I see, good idea. :thumbsup:

Thank you again. :slight_smile:

I still need need to figure why my solution is not working. Any further suggestions are welcome. :wink: