A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
1constr=awaitPromise.race([
2newPromise(res=>setTimeout(()=>res('slow'),10)),
3Promise.resolve('fast'),
4]);
5console.log(r);
Async
Answer & explanation
Console output
fast
Why
Promise.race adopts the state of whichever input promise settles first. Promise.resolve("fast") is already resolved and fires on the microtask queue, while the setTimeout promise needs a 10ms macrotask. Microtasks always run before pending timers, so "fast" wins the race.