Skip to content

Commit 6b90601

Browse files
committed
JS: Simple autoincrement function
1 parent 3001ec7 commit 6b90601

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

JavaScript/autoinc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const autoInc = (() => {
2+
counter = 0;
3+
return () => counter++;
4+
})();
5+
6+
for(let i = 0; i < 10; i++) {
7+
console.log(autoInc());
8+
}

0 commit comments

Comments
 (0)