Home | Mailing List | Blog | Tutorial Videos

Off to the Races

What gets logged?

const p1 = new Promise((resolve, reject) =>
  setTimeout(resolve, 100, 'Hello'));

const p2 = new Promise((resolve, reject) =>
  setTimeout(resolve, 120, 'Goodbye'));

const p3 = new Promise((resolve, reject) =>
  setTimeout(reject, 10, 'Oops!'));

Promise.race([p1, p2, p3])
  .then((result) => console.log(result))
  .catch((reason) => console.log("Something went wrong..."))

Select one: