0
Here’s the code:
//Função para contar os segudos
function conta_seg(){
sec++;
if (sec < 10 && min == 0) {
document.getElementById("conta-tempo").innerHTML = "00:0" + sec;
}else if (sec < 60 && min == 0) {
document.getElementById("conta-tempo").innerHTML = "00" + sec;
}else{
sec %= 60;
min++;
if (min < 10 && sec < 10) {
document.getElementById("conta-tempo").innerHTML = "0" + min + ":0" + sec;
}else if (min < 10 && sec <60) {
document.getElementById("conta-tempo").innerHTML = "0" + min + ":" + sec;
}else if (min < 60 && sec < 10) {
document.getElementById("conta-tempo").innerHTML = min + ":0" + sec;
}else if (min < 60 && sec < 60) {
document.getElementById("conta-tempo").innerHTML = min + ":" + sec;
}
}
}
var clock = setInterval(conta_seg(), 1000);
I checked which error with console.log and found that something was Undefined. What can I do to solve the problem and the program count the seconds normally?
Inês, you are using the variables
sec
andmin
, but in your code apparently they have not been declared anywhere. Try to declare them, that this should solve your problem.– Mateus Daniel
Edit the question and enter the returned error code.
– Augusto Vasques