25+5 Clock Challenge Failing - "Timer has not reached 00:00"

Hey everyone,
so this is absolutely doing my head in :smiley: Spent many hours trying to get the clock pass and researching the forum, but to no avail. Please help.

Code here: fcc-react-project-five/Timer.jsx at secondTry · mrcrazyog/fcc-react-project-five · GitHub

The two following tests keep falling, both with the same error:“Timer has not reached 00:00”:
User Story #22: When a session countdown reaches zero (NOTE: timer MUST reach 00:00), and a new countdown begins, the element with the id of timer-label should display a string indicating a break has begun.

User Story #24: When a break countdown reaches zero (NOTE: timer MUST reach 00:00), and a new countdown begins, the element with the id of timer-label should display a string indicating a session has begun.

However, these two (which look very similar to me), do pass - so in them, somehow, the timer does reach zero (?):
User Story #23: When a session countdown reaches zero (NOTE: timer MUST reach 00:00), a new break countdown should begin, counting down from the value currently displayed in the id="break-length" element.
User Story #25: When a break countdown reaches zero (NOTE: timer MUST reach 00:00), a new session countdown should begin, counting down from the value currently displayed in the id="session-length" element.

Funny thing is, I’ve made a console log that show that the timer DOES reach zero, and I even see it visually. But the tests do not pass. Thanks for any help!

Without seeing the timer in action with an active demo page, and being able to test a few things, its hard to find or confirm a problem, but the two issues you’re failing isn’t about the timer reaching zero(it just says it needs to for the test to pass). What it’s actually checking I believe is that the timer-label is changed whenever the timer reaches zero to indicate if a break or session timer is starting.

Taking a quick glance at your code, it seems timer-label is set by the CurrentTimer state, and setCurrentTimer is only called twice. Both times it sets the value to ‘Session’. I don’t see where you set timer-label to ‘Break’… that might be a place to start.

If you have the link where it is hosted and in live action(like a codePen), it would help us help you :slight_smile:

Thanks so much! :slight_smile: In fact, I did try to post a link to my live working app, but the system thought I was a spammer (maybe because this was my first even post on the forum :smiley: ) and did not allow me to post it, frustratingly :smiley: I’ve hidden the link to the app inside a comment in the code below, hope that does pass the spam bot thing!

Anyways, you actually have brought me on the right track! Thanks to your tip that the script is actually NOT checking whether it does reach 00:00, but rather the related behavior, I started looking elsewhere. And, believe it or not, the issue was to the reset function. I worked to reset the breakToggle hook. Once I did reset it, the code works fine :smiley: I can’t believe I was stuck on this for about ten hours, all because of ONE line of code, lol. But well, I guess that’s how we learn!

The fixed part of code:

//if interested, the live version of the app is at https://pomodoro.michalcak.eu/
  const handleReset = () => {
    clearInterval(loop);
    setLoop(undefined);
    setIsRunning(false);
    setClockCount(25 * 60);
    setBreakCount(5);
    setSessionCount(25);
    setBreakToggle(false);
    setCurrentTimer('Session');
    if (audio) {
      audio.pause();
      audio.currentTime = 0;
    }
  };


Thanks again!

1 Like

Yeah, I would say about 90% of the time I’m stuck on a problem that kills an entire day, it ends up being because of an incorrect sign, or todays was an export I forgot I had made… it’s always the little things.

1 Like