+ 1

Countdown

Okay, so made a simple countdown and tried using clearInterval when the time reaches 0 but my clear Intterval don’t work and it goes below 0 https://code.sololearn.com/W77PeIc8tiiu/?ref=app

4th Mar 2022, 4:39 AM
Junior
Junior - avatar
12 Respuestas
+ 2
You didn't assign the timer ID to any variable. And you call setInterval() method in a wrong place (inside the prompt() method). You need to assign timer ID (returned by setInterval() method) to a variable and use that ID when you want to stop the timer. https://www.w3schools.com/jsref/met_win_setinterval.asp
4th Mar 2022, 8:01 AM
Ipang
+ 1
Okay, one question, so when you get rid of the if(mytime >= 0) and you change the else statement to if(mytime == 0) { clearInterval(mytime) why doesnt it work when i do tgat?
4th Mar 2022, 2:17 PM
Junior
Junior - avatar
+ 1
Nevermind i ubdertaand
4th Mar 2022, 2:58 PM
Junior
Junior - avatar
+ 1
Okay, so isthere any way for me to loop this? I tried but it didnt work https://code.sololearn.com/W77PeIc8tiiu/?ref=app
4th Mar 2022, 3:32 PM
Junior
Junior - avatar
+ 1
Okay, ye ye just testing a few rhing so why doesnt this work? FF9900 https://code.sololearn.com/W4L0oiHm4cqx/?ref=app
4th Mar 2022, 5:10 PM
Junior
Junior - avatar
0
So you always do that?
4th Mar 2022, 5:46 PM
Junior
Junior - avatar
0
Okay, so why is this not working? My alert for my loase button is not working https://code.sololearn.com/W4L0oiHm4cqx/?ref=app FF9900
4th Mar 2022, 6:25 PM
Junior
Junior - avatar
0
Can you explain why mine didnt work so i can undertaand to know what to do next time? FF9900
4th Mar 2022, 7:49 PM
Junior
Junior - avatar
0
Okay, thanks but why do tou have “?” in the code what do they do? FF9900
4th Mar 2022, 8:32 PM
Junior
Junior - avatar
0
Thank you this will help me later on! And should i always use window.onload or when should i use it?
4th Mar 2022, 9:09 PM
Junior
Junior - avatar
0
Okay, trying to add a pause button do you know how to fix? https://code.sololearn.com/W4L0oiHm4cqx/?ref=app
4th Mar 2022, 9:56 PM
Junior
Junior - avatar
0
Jeez your good, okay i dont need the pause button, but can gou make me a reset and a start button?
5th Mar 2022, 9:43 PM
Junior
Junior - avatar