25+5 Clock failing in tests 19, 20 and 21, even though it's working as intended (solved)

I checked all the element’s ids and that’s not the problem.
I suspect it’s because I implemented the timer in a different way than the automated test expects it to be.
In the example project they created a global function which sets the timer (using setTimeout()) and wraps a function or cancel the timer, than this function is called inside the function which handles start / stop timer.
I implemented mine inside the function which handles start / stop timer using setInterval(), which calls a closure to check the time left every 1000 ms and set the states accordingly.
It works exactly the way I wanted and as the description of the tests say, but unfortunately it’s not enough for the automated test.
I don’t want to throw away all my work and the time spent, then end copying and pasting code from the example project only to pass the tests.
Is there anything else I can do?
This is my project’s link

I used setInterval to build a very simple countdown that you can add time to .
For this project it will probably help.

It was a dumb mistake of mine. The timer was taking 2 seconds to start.
I just moved the line ‘timeLeft -= 1;’ to the top of my closure that’s being called by setInterval() and the tests passed.

1 Like

Huh, that’s how i get reminded to check on something when im searching for solution on google these days.

1 Like

I usually search for solution on Google and other places before creating a topic asking for help. I even searched in this forum for the same problem, but I couldn’t find it, probably because I searched for the wrong test numbers, i thought it was 9, 10 and 11 before.
Actually, I almost never ask for help because I like the challenge of trying to solve my own problems alone. But this time the problem was not as noticeable, and the error messages from the tests didn’t help.

1 Like

Yeah, the problem or solution is usually simpler than you think, sometimes dumber than you think.