Pomodoro Clock "Cannot read property '1' of null" error

Hey everyone, I’ve come back to some of the projects on here that I didn’t quite finish on my first pass, and am very stuck on the Pomodoro Clock of the Front End Libraries projects. Here is the CodePen, if you’d like to take a look. A warning: the beeping sound is a little loud currently, so maybe adjust your volume to avoid an unwelcome surprise.

Currently, the project fails test 12 and 15 both with the somewhat vague error of Cannot read property '1' of null. It seems like others on here have attributed that to the time display not appending a “0” to the beginning of the single-digit minute times, but I can’t detect that problem happening here (could still be there though!). The other test that is failing is 13, the reason being Timer has reached zero but didn't switch to Break time, having to do with the element with an ID of timer-label. Again, from my human eye this seems to be working, and I can’t quite figure out what’s gone wrong. Any advice would be greatly appreciated!

Hey Murphy,

you can have a look at the project tests.

Try to debug it on your own and
let us know if you need some additional help.

Hey Miku, I did manage to solve the problem! The problem was that I had a piece of code checking to see if the seconds left on the timer was below zero, which did achieve the effect of letting the timer reach 00:00. I changed that to check if the time left was below one second, which now seems to not allow the timer to reach 00:00, but all tests are passing. This is that modified code (I’m using React Hooks):

useEffect(() => {
    if (secondsLeft < 1) {
      document.getElementById("beep").play()
      setIsInBreak(isInBreak => !isInBreak);
    }
  }, [secondsLeft])

I spent a while looking at the tests to try to determine what was different about the tests perception of the timer reaching zero compared to my own eye, but can’t quite figure it out. Hopefully though this is useful to someone in the future facing a similar issue!

Great work solving it on your own! :+1: