aboutsummaryrefslogtreecommitdiffstats
path: root/2620
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2024-01-03 08:20:27 +0000
committerterminaldweller <devi@terminaldweller.com>2024-01-03 08:20:27 +0000
commitd0a9df1754e2c9182f5b3a3a30682b37014e6206 (patch)
treec1059f5c15f76943661c85dbd17ab4def4f75c99 /2620
parent2704 (diff)
downloadleetcode-d0a9df1754e2c9182f5b3a3a30682b37014e6206.tar.gz
leetcode-d0a9df1754e2c9182f5b3a3a30682b37014e6206.zip
2125,2620,2667
Diffstat (limited to '2620')
-rwxr-xr-x2620/main.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/2620/main.js b/2620/main.js
new file mode 100755
index 0000000..da3ecbe
--- /dev/null
+++ b/2620/main.js
@@ -0,0 +1,18 @@
+#!/usr/bin/env node
+"use strict";
+
+/**
+ * @param {number} n
+ * @return {Function} counter
+ */
+var createCounter = function (n) {
+ var count = n;
+ return function () {
+ return count++;
+ };
+};
+
+const counter = createCounter(10);
+console.log(counter()); // 10
+console.log(counter()); // 11
+console.log(counter()); // 12