Stuck on Pomodoro Clock with React

Hi everyone, i’m very stuck on this FCC challenge. In practice, my code go until 00:00 and change to a session or break, but when I launch the test, the first test under #timer says:

Timer has not reached 00:00.
Error: Timer has not reached 00:00.
at https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:657:168153

And goes the same for 9 to 15 test on this hashtag. I’ve been searching and i think it’s because “setInterval” does not decrement exactly, but I don’t know how can I fix it. Here’s my code:

A Pen by Uriel Gomez Raga (codepen.io)

So please, would someone give an advice to fix my code? I’ve been stuck for almost two weeks. By the way, excuse my poorly english, I’m not a native speaker.

It’s failing a number of different test. Just a couple things to note as to the ones you mentioned though.

  1. Your timer starts off on Break, but it should start off on Session.

  2. When your timer reaches 00:00 and switches from a break to a session, it displays the timer incorrectly formatted as “0-1:0-1”.

Intersting, I thought i was starting on Session. Let me check. But when it reaches 00:00, how can I fix it?

Two issues I see…

  1. Your initial state is set to Break and should be set to Session.

  2. When your countdown reaches zero, you never set it to the break or session length, so it continues counting down into negative numbers. You need to set the state to the break or the session length when it reaches 00:00.

check if the seconds are 0 and the minutes are zero, if they both are then set the render to “00:00” and change your countdown variable to the break minutes, also, add an onBreak property on your state because you will also need to toggle from break to session

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.