What is the value of result when Promise.race executes?

Refer to the code below:

Let car1 = new Promise((_ , reject) =>

setTimeout(reject, 2000, “car 1 crashed in” =>

Let car2 =new Promise(resolve => setTimeout(resolve, 1500, “car 2 completed”)

Let car3 =new Promise(resolve => setTimeout(resolve, 3000, “car 3 completed”)

Promise.race(( car1, car2, car3))

.then (value => (

Let result = ‘$(value) the race.’;)}

.catch(arr => {

console.log(“Race is cancelled.”, err);

});

What is the value of result when Promise.race executes?
A . Car 3 completes the race
B . Car 2 completed the race.
C . Car 1 crashed in the race.
D . Race is cancelled.

Answer: B

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments