Stop Interval After N
NodeJS
Easy
4 views
Problem Description
Run setInterval and stop after 3 ticks, print count.
Output Format
Print integer.
Constraints
Use clearInterval.
Official Solution
let n = 0;
const id = setInterval(() => {
n += 1;
if (n === 3) {
clearInterval(id);
console.log(n);
}
}, 10);
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!