0

Why doesn't this code work? (Am I making and obvious mistake)?

Here is my code: var num = 0; function upNum() { num++; document.getElementById("count").innerHTML = num; } function countms() { var time = 0; time++; return time; } if(num === 10000) { clearInterval(count); document.getElementById("count").innerHTML = "Your still here?"; if(setInterval(countms, 1) === 5000) { setInterval(upNum, 1); } } var count = setInterval(upNum,1); Please let me know if you find a error in my code.

8th Jun 2018, 3:38 AM
Kenzoid
Kenzoid - avatar
1 Antwort
+ 1
if (setInterval(countms, 1) === 5000 ) ===> setInterval return interval_id. You never know when that's going to be 5000. Also everytime you call countms, it will always return 1
8th Jun 2018, 3:53 AM
Gopal Gautam
Gopal Gautam - avatar