Spot the bug in catalog traversal

from Iterators and generators
Node 24 intermediate 4 min 1 issue to find

Find why the second traversal of this catalog is empty.

JavaScript
function makeCatalog(items) {
  const iterator = items.values();
  return {
    [Symbol.iterator]() {
      return iterator;
    },
  };
}

const catalog = makeCatalog(['pen', 'book']);
console.log([...catalog]);
console.log([...catalog]);
Open in playground
Report an error