Implement a function cancellableInterval(callback, delay) that behaves like setInterval but returns a function to cancel the interval.
Example
let count = 0; const cancel = cancellableInterval(() => { count++; }, 100); setTimeout(() => { cancel(); // stop the interval }, 350); // After 350ms, count should be 3 (roughly)
JavaScript Function
No test results yet
Click "Run" to execute tests