If you set the variable interval globally, it works normally.
But I want to save the variable interval inside stopWatch() and then call the interval value with hiddenPopUp().
The code below doesn't seem to be able to return an interval...
function stopGame() {
hiddenPopUp(stopWatch);
}
// let interval;
function stopWatch() {
let interval = setInterval(() => {
if (timeStart < 0) {
clearInterval(interval);
return;
} else {
time(timeStart);
}
}, 1000);
return interval;
}
function hiddenPopUp(interval) {
clearInterval(interval);
}