Refer to the code below:
let car1 = new Promise((_ ,reject)=> setTimeout(reject,2000,"Car1 crashed in"));
let car2 = new Promise(resolve => setTimeout(resolve,1500,"Car2 completed"));
let car3 = new Promise(resolve => setTimeout(resolve,3000,"Car3 completed"));
Promise.race([car1,car2,car3])
.then(value=>{
let result = `${value} the race.`;
}).catch(err=>{
console.log('Race is cancelled.',err);
});
What is the value of result when promise.race execues?
Currently there are no comments in this discussion, be the first to comment!