Set Interval glitching

Will somebody please help with my problem. My set interval works fine the first few runs but then begins to glitch out. I am trying to make it so that when one timer ends the next one begins. Thank you.

1 Like

What is the main purpose for the code actually …
( I mean if I know what you want to do I could actually keep that in mind then review the code ) …
because you have named them minutes and seconds but its not actually working like minutes anything in there .
Or
you just want the code for counting t-5 seconds alternately for infinite?

sorry I always name things strangely. Right just ignore the minutes part, I am simply debugging the seconds for now. If you change the test variable, that will change the amount of time the timers will count down from. Right now, I want one timer to count down and then hit zero, which will cause the second timer to activate, when that one hits zero, the other timer will re-activate…and that will go on forever.

It does it correctly three times, and then begins to skip numbers is the problem.

Part of your problem is that you made interval2 local to timed with the following line:

var interval2 = setInterval(breaker, 1000);

Declaring interval2 outside both functions will help, but not solve all your problems.

After fixing the above issue, you still have a logic error somewhere in your code. I think the actual problem is hard to see because of the way you have named your variables. I would rename time to sessionSecond(assuming this is for the pomodoro clock project) and rename minute to sessionMinute.

Thank you! I will try to find it.