Skip to content

Commit c7bcbc2

Browse files
add 2620
1 parent 2ddd24e commit c7bcbc2

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Diff for: javascript/_2620.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @param {number} n
3+
* @return {Function} counter
4+
*/
5+
var createCounter = function (n) {
6+
let counter = n;
7+
8+
return function () {
9+
return n++;
10+
};
11+
};
12+
13+
/**
14+
* const counter = createCounter(10)
15+
* counter() // 10
16+
* counter() // 11
17+
* counter() // 12
18+
*/

Diff for: paginated_contents/javascript/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
| # | Title | Solutions | Video | Difficulty | Tag
22
|------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|--------------------------------------|------------------------------------------|----------------------------------------------------------------------
33
| 2703 | [Return Length of Arguments Passed](https://leetcode.com/problems/return-length-of-arguments-passed/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/javascript/_2703.js) | | Easy | Javascript
4+
| 2620 | [Counter](https://leetcode.com/problems/counter/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/javascript/_2620.js) | | Easy | Javascript
45
| 2619 | [Array Prototype Last](https://leetcode.com/problems/array-prototype-last/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/javascript/_2619.js) | | Easy | Javascript

0 commit comments

Comments
 (0)