Implement a function cancellableTimeout(callback, delay) that behaves like setTimeout but returns a function to cancel the pending callback.
Example
let called = false; const cancel = cancellableTimeout(() => { called = true; }, 100); cancel(); // Cancel the timeout before it runs console.log(called); // false
JavaScript Function
No test results yet
Click "Run" to execute tests