Skip to content

Commit b60ebd8

Browse files
committed
solved the problem counter
1 parent e2f85ec commit b60ebd8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Easy/JavaScript/counter.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var createCounter = function (x) {
2+
let privateCounter = x - 1;
3+
return function () {
4+
return (privateCounter += 1);
5+
};
6+
};
7+
8+
const counter = createCounter(20);
9+
console.log("🚀 ~ file: counter.js:10 ~ counter:", counter());
10+
console.log("🚀 ~ file: counter.js:10 ~ counter:", counter());
11+
console.log("🚀 ~ file: counter.js:10 ~ counter:", counter());

0 commit comments

Comments
 (0)