$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · hard · #72

Which fix removes the bug?

async function all(ids) {
  const out = [];
  ids.forEach(async (id) => {
    out.push(await load(id));
  });
  return out;
}
  1. Use await Promise.all(ids.map(load))
  2. Use await Promise.race(ids.map(load))
  3. Add await before the ids.forEach call
  4. Change out.push to out.concat inside
forEach ignores the async callbacks, so out is still empty at the return; Promise.all waits.
Play Problem Solving ▸