25+5 Clock - Help. expected 0 to be above 0 - SOLVED sorta

Hi all!

I’m working on the 25+5 clock and I am currently passing 26/29. The 3 i fail all show similar reasons. I didn’t have any of these issues originally :frowning:

here is a link to my project on codepen: https://codepen.io/Malik_Mortis/pen/qBRJQeO

These have been updated (5/9/21 2:45 EDT)

  • 9 shows: 25 + 5 clock has started but time displayed is not changing : expected 0 to be above 0
  • 10 shows: 25 + 5 has started but time displayed is not changing: expected ‘00’ to not equal ‘00’
  • 11 shows: 25 + 5 clock has started but time displayed is not changing: expected ‘00’ to not equal ‘00’

specifically tests: it now fails 9, 10, and 11

NOTE: it is currently pretty ugly, i like to pretty it up once it actually works, and controls on audio are visible for testing

Please Help! This is getting sooooo frustrating :rage:

UPDATE 1: My current thinking is that the timer doesn’t start with the starting time… ex: 5min break goes from 00:00 to 4:59; I’m working on changing how it works, in hopes it solves the issue

UPDATE 2: I changed some things, solving most of my issues, all of the timer has not reached 0, but now i fail 9 10 and 11… error message updated

FINAL UPDATE: I changed how my clock works completely. twotani made me realize i could just decrement a set time instead of using date. I had to start over but it simplified my code and I finally pass everything!
clock pass

here is my new version: version 2.0

I had a similar issue, and I share your frustration. What is happening, I believe, is that the timer did not lapse 1 second for showing the value of 0. In other words, display of all non-zeroes stayed on the display for one second, but the display of 0 disappears immediately. I solved the problem by changing my countdown function to

const countdown = () => {
  if (timeLeft < 0) switchClock();

Initially I tested for timeLeft == 0 to switchClock() and then decrement the counter. By changing the code to decrementing the timeLeft counter before test and testing it for < 0 makes the display of 0 stay for one second.
I hope this helps. Also, when I had a problem, the tests ran for a long time because I think they repeatedly ran the same tests. If there’s no problem, the tests will complete fairly quickly.

Thank you for responding and trying to help!

To make sure I am understanding, you are saying you believe the issue is that my 00:00 does not display long enough?

Yes, that’s what I suspect, since that was the case for me.

Interesting, I’m fiddling with something of the sort now


thank you so much @twotani . Your example helped me solve and issue but more importantly made me realize there was a simpler way of doing things…

Instead of using date as endtime = date + timer etc… i just use endTime ## and decrement by 1000 milliseconds (could use seconds but i like to stick to milliseconds since that is what interval uses)

Yay. Cheers!

That error was really frustrating. Glad to hear your coding is working now.

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