← Back to archive

Stdle #170 · async · 2026-11-17

What does this JavaScript snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

function* counter() { let n = 0; while (true) yield n++; }
const c1 = counter();
const c2 = counter();
console.log(c1.next().value, c1.next().value, c2.next().value);
Async
4 attempts left

Answer & explanation