0
I am creating a JS team to count the time it will take the user to complete the task. I am using setInterval()
to run the team but I’m not able to increase to more than (1) the value of min()
. This is my code:
const time = {
min: 0,
sec: 0,
getSec: function(){
this.sec++;
if (this.sec === 59) {
this.min=+1;
this.sec =0;
}else {
if (this.sec >= 59) {
this.sec = '00';
this.min=+1;
}
}
},
}
$sT = $('.score-panel').find('#time');
function setTime () {
setInterval(function(){
time.getSec();
$sT.html(time.min + ':' + time.sec);
},1000)
}
window.clearInterval(setTime());
the if
within the else
was an attempt to increase the minutes as the seconds go to 59.
The window.clearInterval()
is to stop time when the user changes screen.
Bro thanks for real, I fix here and it worked now yes this incrementing the minutes. Thank you really, God bless you man.
– Wemerson Nino
I hadn’t really realized the assignment of
=+
thanks man.– Wemerson Nino