freecoding.school100% FREE · NO SIGNUP
Await StationISSUE #5 of 26

promises · all · allSettled · race · any

PromissaVSRace Condition Rex
Promissa saysPromise.all/allSettled/race/any combine multiple promises in different ways.

Promise.all([…]) waits for all (rejects if any do); allSettled waits for all and reports each outcome (never rejects); race settles with the first to finish (success or fail); any resolves with the first success. Use all for parallel fetches, allSettled when partial failure is OK.

Power-ups you unlock

Race Condition Rex attacks — common mistakes

Boss battleRun three timeouts in parallel with Promise.all and log when all finish.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre id="o"></pre>
<script>const wait=(ms,v)=>new Promise(r=>setTimeout(()=>r(v),ms));
Promise.all([wait(200,'a'),wait(400,'b'),wait(300,'c')]).then(vals=>document.getElementById('o').textContent='all done: '+vals);</script></body></html>
▶ Open the interactive comic issue
‹ Promises · Then · Catch · FinallyAsync / Await · Sugar For Promises ›