Module Maze · Level 7 of 8

CommonJS hands you a copy

The same counter, written in CommonJS and destructured on require.

main.cjs
const { count, increment, get } = require('./counter.cjs');console.log('count is ' + count);increment();console.log('count is ' + count);console.log('module sees ' + get());
counter.cjs 6 lines
let count = 0;module.exports = {  count,  increment() { count++; },  get() { return count; },};

1. Predict the output

Tap the lines in the order you think they print.

  1. 1…
  2. 2…
  3. 3…