Pomodoro Clock app!

Hello, i am working in pomodoro clock:
https://codepen.io/Stivi7/pen/KvexyZ here is the code until now, but when i try it with small values like the var of seconds = 5 and minutes are 1 or 2, it comes a time that it get messed up! I cant figure it out which call is wrong! If someone helps me, would be very grateful!
Thanks in advance!

I briefly looked at your code, so I can not really give a detailed troubleshoot ATM , but here are some pointers

  • you have too many set intervals , be-careful with many set intervals / set timeouts , as the interval ID’s will get cluttered and mess you up if not careful. For this project, you should really only need 2 set Intervals, you have 4, I understand you want separate intervals for minutes/seconds , but it is not necessary, you can parse your hours/minutes/seconds easily by keeping a record of how many total intervals you have run in ms.
  • some of your naming conventions are confusing , like your interval ID names are very similar to the recursive functions they are calling

this is the basic structure I used to complete this project below

set interval for work()
    do whatever ==> display time , graphics , etc...
    check time
       if time is not up ==>  keep on doing whatever ==> display time , graphics , etc...
       if time is up ==> Clear work interval, start Break interval

set interval for break()
    do whatever ==> display time , graphics , etc...
    check time
       if time is not up ==>  keep on doing whatever ==> display time , graphics , etc...
       if time is up==> Clear break interval, start Work interval
1 Like