commit b992f73a866ea8d18257bbefa9e9ec6ae83241fb
parent 78b7489d614d3b618b75857bd22a123c284d331d
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Fri, 19 May 2023 21:38:09 +0200
JavaScript Challenge: Day 15
Diffstat:
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/Problems/2627.js b/Problems/2627.js
@@ -0,0 +1,15 @@
+/**
+ * @param {Function} fn
+ * @param {number} t milliseconds
+ * @return {Function}
+ */
+
+var debounce = function(fn, t) {
+ let timeout;
+ return function(...args) {
+ clearTimeout(timeout);
+ timeout = setTimeout(() => {
+ fn(...args)
+ }, t);
+ };
+};
diff --git a/README.md b/README.md
@@ -545,6 +545,7 @@ for solving problems.
| 2622 | Medium | [Cache With Time Limit](Problems/2622.js) |
| 2623 | Medium | [Memoize](Problems/2623.js) |
| 2626 | Easy | [Array Reduce Transformation](Problems/2626.js) |
+| 2627 | Medium | [Debounce](Problems/2627.js) |
| 2629 | Easy | [Function Composition](Problems/2629.js) |
| 2632 | Medium | [Curry](Problems/2632.js) |
| 2634 | Easy | [Filter Elements from Array](Problems/2634.js) |