Your Submissions
You haven't submitted any code for this challenge yet. Solve the problem by passing all the test cases, and your submissions will appear here.
xxxxxxxxxx53
// Assuming window object in a Node.js environment for demonstration purposes.global.window = { timeouts: [], setTimeout: function(callback, delay) { const id = Math.random(); // Random ID for demonstration; usually, you'd use a more deterministic way this.timeouts.push({ id, callback, delay }); return id; }, clearTimeout: function(id) { this.timeouts = this.timeouts.filter(timeout => timeout.id !== id); }, clearAllTimeouts: function() { // Your implementation goes here }, // Utility method to emulate 'tick' of the event loop _tick: function() { this.timeouts.forEach(timeoutObj => timeoutObj.callback()); }};// Test cases for window.clearAllTimeoutsfunction runTests() { let test1Flag = false; let test2Flag = false; // Schedule some timeouts const timeout1 = window.setTimeout(() => { test1Flag = true; }, 1000);OUTPUT
Results will appear here.