25+5 Clock Audio test 1 fails

I have written code that is explicitly set to listen for audio playing at timer 00:00 yet it fails Audio test 1. If I make it pass Audio test 1 by delaying execution on code that follows after audio.play() by about 600milliseconds, audio test passes but then it fails on other tests that should happen at timer 00:00.
I also want to ensure that timer is correctly reading passing of time, thus I have used setInterval based on current Date().getTime() rather than using setTimeout to update the clock timer readout. How can I make it pass all the tests or what do you think is the reason for it failing?

My code can be accessed at following link:

PLEASE HELP
PLEASE HELP

Have you tried it without the Date code?

I have definitely seen others have issues with this project when using that approach. Or at the very least it seems to break the setInterval/setTimeout hack the test does which makes it take forever to run, making debugging it very tedious.

you are correct that it makes the tests run a lot slower but all of them do run in about 5minutes or so. What do you mean by trying it without the Date code? Could you expand on that a bit?

Just have setInterval code that decrements a state value. You do not need to use a date to keep track of time.

If you search for react countdown timer you can see a bunch of examples.

If I do it this way then how would it account for the time taken to parse through my lines of code?

Not sure what you mean?

Code execution is super fast and the code responsible for the timer is just a small part of it. You do not need to do anything special.

There are more precise timers that try to account for issues that can arise if the user switches to a different tab as that can cause the browser to throttle the timers. But other than that you really do not need to do anything to make an accurate countdown timer.

okay I will try accomplishing this challenge with the countdown variable rather than actual time passes as you suggested. Sidenote: When running, I printed remaining time to console when it was less than zero. I saw everything from -1 to -900 which suggested to me that it may be off by a about 1 second even though code execution is super fast.

I would need to see an example.

But I can assure you setInterval decrementing a value is not going to be affected in any significant way unless something is very wrong. Sure it can drift over time and it isn’t as precise as say the Performance APIs if you need to measure time super accurately. But I haven’t seen any code using setInterval fail the tests because of timing issues.

Thanks for your help. I made another version without using new Date().getTime() and used setInterval for the countdown. It now passes all the tests. One thing I noted that for it to pass the test, I had to give setInterval a delay time of less than 1000 so that code block is executed multiple times in one second. If I execute code only once in 1 second, it fails some tests. On other hand, if I set interval delay to only 100, it also fails some tests. I chose 400 for setInterval delay and clocks seems to be working as intended each time I run it - passes all tests, thank you.

New clock link: