Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Implement a function to debounce another function, delaying its execution until after a specified interval.

Hard

Problem Statement

Implement a function to debounce another function, delaying its execution until after a specified interval.

Sample Input

Function to be debounced: logMessage
Debounce interval: 300 ms
Number of times logMessage is called in a row: 3

Sample Output

Only one output after 300ms of inactivity.

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
// Implement debouncing to delay function execution function debounce(func, delay) { // Initialize a timer variable // Return a function that clears the timer and sets a new one } // Example function to debounce function logMessage() { // Log a message to the console } const debouncedLog = debounce(logMessage, 300); debouncedLog(); debouncedLog(); debouncedLog();
Log in or sign up to run or submit your code.Log inSign up
Input
Function to be debounced: logMessage
Debounce interval: 300 ms
Number of times logMessage is called in a row: 3
Expected Output
Only one output after 300ms of inactivity.