← Back to archive

Stdle #19 · scope · 2026-06-19

What does this JavaScript snippet output?

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

const fns = [];
for (let i = 0; i < 3; i++) { fns.push(() => i); }
console.log(fns.map(f => f()).join(","));
Scope
4 attempts left

Answer & explanation