← Back to archive

Stdle #83 · async · 2026-08-22

What does this JavaScript snippet output?

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

const log = [];
for (const n of [1, 2]) {
await Promise.resolve();
log.push('for' + n);
}
[3, 4].forEach(async n => { log.push('each' + n); });
console.log(log.join(','));
Async
4 attempts left

Answer & explanation