[UPDATE: I appreciate the assistance from everyone. I can see that my question received some criticism for lack of research and other factors. My apologies for any oversights, and thank you for your understanding. As a newcomer to coding and stackoverflow, I am still navigating the rules and norms.]
Why does this script not cease after displaying 'DONE' once? Is there a simple solution?
function countdown(num) {
let n = num;
function dec() {
if (n > 1) {
n--;
console.log(n);
} else {
clearInterval(dec);
console.log('DONE!');
}
}
setInterval(dec, 1000);
}
Your input and guidance are appreciated!