How to set count down timer in JavaScript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to set count down timer in JavaScript

I want to set a timer for 30 minutes and it should count down and come to 0 using java script I used setInterval() and setTimeout() but it is not working

16th Apr 2017, 11:31 AM
Rupal Gujrathi
Rupal Gujrathi - avatar
5 Answers
+ 2
function myTimeoutFunction() { doStuff(); setTimeout(myTimeoutFunction, 1000); } myTimeoutFunction();
16th Apr 2017, 11:43 AM
Rupal Gujrathi
Rupal Gujrathi - avatar
+ 1
setInterval(function(){ doStuff() }, 1000);
16th Apr 2017, 11:45 AM
Yaroslav Pieskov
Yaroslav Pieskov - avatar
+ 1
you can check my first code here(Session Timer),it's all about intervals using only native js,maybe it will help you to undestand how things work... It was my first js experiments :D
16th Apr 2017, 10:20 PM
Rose Sevenyears
Rose  Sevenyears - avatar
- 1
show your code with setInterval
16th Apr 2017, 11:41 AM
Yaroslav Pieskov
Yaroslav Pieskov - avatar
- 2
function doStuff() { alert("go to next"); }
16th Apr 2017, 11:45 AM
Rupal Gujrathi
Rupal Gujrathi - avatar