Question 13
Consider the below javascript program.
const promiseChain = new Promise((resolve, reject) => { console.log('Step 1'); resolve(1); }) .then((value) => { console.log('Step 2:', value); return value + 1; }) .then((value) => { console.log('Step 3:', value); throw new Error('Error in Step 3'); }) .then((value) => { console.log('Step 4:', value); return value * 2; }) .catch((err) => { console.log('Caught:', err.message); return 5; }) .then((value) => { console.log('Step 5:', value); return value + 1; });
console.log('End of Code');What will be the output of the above program?
Step 1
Step 2: 1
Step 3: 2
Caught: Error in Step 3
End of CodeStep 1
Step 2: 1
Caught: Error in Step 3
Step 5: 5
End of CodeStep 1
Step 2: 1
Step 3: 2
End of CodeStep 1
End of Code
Step 2: 1
Step 3: 2
Caught: Error in Step 3
Step 5: 5