Counter I in JavaScript and TypeScript
Complexity
Time complexity: O(1)
Space complexity: O(1)
Code
# Complexity
- Time complexity: O(1)
- Space complexity: O(1)

# Code
```javascript []
/**
 * @param {number} n
 * @return {Function} counter
 */
var createCounter = function(n) {
    return () => n++;
};

```

```typescript []
function createCounter(n: number): () => number {
    return () => n++;
}
```
['TypeScript', 'JavaScript']