Stuck at last test of Pomodoro Clock

Tell us what’s happening:
So I was trying to finish this Pomodoro Clock challenge. I managed to pass 28 out of 29 tests after multiple attempts, but have no clue how to solve this Audio Test: "When a countdown reaches zero (NOTE: timer MUST reach 00:00), a sound indicating that time is up should play. "

Any help would be great!

Your code so far
Here’s my code here: https://codepen.io/MourningCat/pen/RwWyGqO

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36.

Challenge: Build a Pomodoro Clock

Link to the challenge:
https://www.freecodecamp.org/learn/front-end-libraries/front-end-libraries-projects/build-a-pomodoro-clock

I think I figured it out. Your audio doesn’t play when the clock hits 00:00, it plays when the clock loads the next session/break.

 if (time == -1) {
      this.playAudio()
      this.toggleBreakSession()

This is why.

1 Like

Okay good point, but I set time == -1 so that this execution will be triggered when the remaining time == 0, it shouldn’t affect the audio playing

Right, so at time == -1 it runs the audio and switches the session. Switching the session is correct, but it should run the audio at time == 0 because you want the audio to play when the clock displays 00:00, not after.

I just edited my code based on your advice and it passed. Thank you so much my friend!

I’m glad I could help! Now take a moment to celebrate your success!