Skip to content
Junior–Senior166 views

What will be the output of Promise.race with different timeouts

Task condition

Determine what value will appear in the console after executing this code:

const p1 = new Promise((resolve) => setTimeout(resolve, 500, "1"));
const p2 = new Promise((resolve) => setTimeout(resolve, 100, "2"));

Promise.race([p1, p2]).then((result) =>
  console.log(result)
);
Frontend tasks in the code trainer