cf.completefrontend

Predict the outputMedium

What does this counter log for its count property after a few increments?

What does this log?
function createCounter() {
  let count = 0;
  return {
    count,
    increment() {
      count++;
      return count;
    },
    reset() {
      count = 0;
    },
  };
}
 
const counter = createCounter();
counter.increment();
counter.increment();
console.log(counter.count, counter.increment());
counter.reset();
console.log(counter.count, counter.increment());

The answer

Work out every line it logs, in order. Then check.

Checking your sign-in…