Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce JS-Dev-101 Exam - Topic 5 Question 11 Discussion

Posted by Carmen on Jun 28, 2026 at 10:14 AM

Refer to the code:

01 function execute() {

02 return new Promise((resolve, reject) => reject());

03 }

04 let promise = execute();

05

06 promise

07 .then(() => console.log('Resolved1'))

08 .then(() => console.log('Resolved2'))

09 .then(() => console.log('Resolved3'))

10 .catch(() => console.log('Rejected'))

11 .then(() => console.log('Resolved4'));

What is the result when the Promise in the execute function is rejected?

Suggested Answer: D

execute() returns a Promise that immediately calls reject().

So promise starts in a rejected state.

When a Promise is rejected and you chain .then() calls without rejection handlers, all those .then() callbacks are skipped until a .catch() is encountered:

promise

.then(...) // skipped

.then(...) // skipped

.then(...) // skipped

.catch(...) // executed

.then(...); // executed after catch

Execution:

.then(() => console.log('Resolved1')) is skipped.

.then(() => console.log('Resolved2')) is skipped.

.then(() => console.log('Resolved3')) is skipped.

.catch(() => console.log('Rejected')) runs and logs Rejected.

The .catch() returns a resolved Promise (no explicit return, so undefined), so the next .then() runs:

.then(() => console.log('Resolved4')) logs Resolved4.

Final output:

Rejected

Resolved4

This matches option D.


Get Premium JS-Dev-101 Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
23 comments · newest first
JI
Jill 2 days ago
I think the answer is B.
NA
Nana 7 days ago
I’m leaning towards D as well.
ST
Stephane 13 days ago
I see both sides, but D makes sense too.
RA
Raina 18 days ago
I agree with Freeman, B is the clear answer.
DO
Dong 23 days ago
But D shows the flow after catch.
RO
Rory 28 days ago
Exactly, B is too simple.
PO
Polly 1 month ago
Why D? The catch handles the rejection.
FA
Fatima 1 month ago
I feel like it's D) Rejected Resolved4.
FR
Freeman 1 month ago
I think it's B) Rejected.
GO
Golda 2 months ago
No way, it's just B) Rejected for sure!
TR
Tresa 2 months ago
I think it's A) because of the chained then.
JA
Jani 2 months ago
Wait, why would it log Resolved4? That seems off.
DE
Deja 2 months ago
Definitely B) Rejected.
MA
Maryann 2 months ago
The promise is rejected right away.
MA
Matt 2 months ago
No way it’s A, it has to be B!
EV
Evelynn 3 months ago
I think it’s A) but I’m not sure.
DE
Desire 3 months ago
Wait, why does it say Resolved4? That seems off.
RO
Rory 3 months ago
Definitely B) Rejected!
JA
Jade 3 months ago
The promise is rejected right away.
HU
Huey 3 months ago
I feel like the answer might be D, because after the catch, it could still run the last 'then' for 'Resolved4'. But I could be wrong!
PR
Precious 4 months ago
This reminds me of a practice question where the promise was resolved, and all the 'then' statements executed. But here, since it's rejected, I guess it skips to the catch.
DE
Deane 4 months ago
I'm not entirely sure, but I remember something about how the catch block handles rejections. Maybe it just outputs 'Rejected'?
DE
Devorah 4 months ago
I think the promise gets rejected right away, so it won't execute any of the 'Resolved' logs before the catch.
0/2000 characters

Save Cancel