148. create a counter object

JavaScript
Is this helpful ?

easy  - accepted / - tried

Create an object with property count, which increments every time count is accessed, initial value is 0.

const counter = createCounter()
counter.count // 0, then it should increment
counter.count // 1
counter.count // 2
counter.count = 100 // it cannot be altered
counter.count // 3

Let's try to solve this problem within 10 minutes.

Discuss(70)