Hello,
I have created a countdown function, which is working correctly. The only problem is that I can not interrupt it. I made all sorts of adaptations with return and clearInterval (), it stops for a second and then returns to execution.
This is the function:
function startTimer() {
let timeValue = $('#clock').text();
timeValue = timeValue.split(":");
let minutes = parseInt(timeValue[0]);
let seconds = parseInt(timeValue[1]);
if (minutes > 0 || seconds > 0) {
if (seconds == 00) {
minutes--;
seconds = 59;
} else {
seconds--;
}
$('#clock').text((minutes > 9 ? minutes : '0' + minutes) + ':' + (seconds > 9 ? seconds : '0' + seconds));
pomodoroPercent();
} else {
$('#clock').text('00:00');
pomodoroEnd();
return;
}
setTimeout(startTimer, 1000);
}