Exam JavaScript-Developer-I Topic 6 Question 10 Discussion
Actual exam question for Salesforce's JavaScript-Developer-I exam
Question #: 10
Topic #: 6
Question #: 10
Topic #: 6
Refer to the code below (assuming Promise.race is intended):
let cat3 = new Promise(resolve = >
setTimeout(resolve, 3000, " Cat 3 completes " )
);
Promise.race([cat1, cat2, cat3])
.then(value = > {
let result = `${value} the race.`;
})
.catch(err = > {
console.log( " Race is cancelled: " , err);
});
(Assuming cat1 and cat2 are similar to earlier examples: cat2 resolves fastest.) What is the value of result when Promise.race executes?
let cat3 = new Promise(resolve = >
setTimeout(resolve, 3000, " Cat 3 completes " )
);
Promise.race([cat1, cat2, cat3])
.then(value = > {
let result = `${value} the race.`;
})
.catch(err = > {
console.log( " Race is cancelled: " , err);
});
(Assuming cat1 and cat2 are similar to earlier examples: cat2 resolves fastest.) What is the value of result when Promise.race executes?
Suggested Answer: A Vote an answer
From earlier pattern (cars/cats race):
* One promise resolves the fastest with " Car 2 completed " (or analogous " Cat 2 completes " ).
* Promise.race resolves with the first settled promise's value.
* In .then, value is " Car 2 completed " and:
let result = `${value} the race.`;
// " Car 2 completed the race. "
Thus result is " Car 2 completed the race. " # option A.
* One promise resolves the fastest with " Car 2 completed " (or analogous " Cat 2 completes " ).
* Promise.race resolves with the first settled promise's value.
* In .then, value is " Car 2 completed " and:
let result = `${value} the race.`;
// " Car 2 completed the race. "
Thus result is " Car 2 completed the race. " # option A.
by Baron at Aug 14, 2026, 01:02 AM
0
0
0
10
Comments
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Report Comment
Commenting
You can sign-up / login (it's free).