Example code to demonstrate differences between time complexities.
Install dependencies:
npm install
Start program:
npm start
- Initialize a new instance of the Counter class inside a function:
const counter = new Counter();
- For each step, call the increment function
counter.inc();
- Get the total count by using the total property
const total = counter.total;