cf.completefrontend

Write the codeEasy

Write runInSeries(tasks): run async functions one after another and collect their results.

tasks is an array of functions that each return a promise or a value. Start each one only after the previous one has finished, and resolve with the results in order. If a task fails, reject with its error, and don't start the tasks after it.

Write this
async function runInSeries(tasks) {
  // your code
}
 
// const [a, b] = await runInSeries([
//   () => fetchJson("/a"),
//   () => fetchJson("/b"),
// ]);

Solve it in the editor, with tests

The answer

Write it yourself first. Then compare it with a reference solution and the checks it passes.

Checking your sign-in…