let count = 0;
function printCount() {
console.log("Count:", count);
count++;
if (count > 5) {
clearInterval(intervalId);
}
}
let intervalId = setInterval(printCount, 1000); clearInterval(intervalId);
I do not understand why its not working on Google Chrome console. Can you help me please?
clearInterval is executed right after setInterval. Below may be work