Implement robust debounce and throttle in JavaScript | Amazon Interview Question