Mark As Completed Discussion

One Pager Cheat Sheet

  • With window.setTimeout() and window.clearTimeout(), you can schedule and clear timeouts, respectively, but can you write a method, window.clearAllTimeouts, to clear multiple timeouts at once?
  • We have overwritten the native window.setTimeout and window.clearTimeout functions to add and remove timer IDs to/from a Set collection, in order to implement a custom clearAllTimeouts function.
  • ClearAllTimeouts iterates through each timer and manually clears it.

This is our final solution.

To visualize the solution and step through the below code, click Visualize the Solution on the right-side menu or the VISUALIZE button in Interactive Mode.

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment

Got more time? Let's keep going.

If you had any problems with this tutorial, check out the main forum thread here.