+1 vote
in NodeJS Essentials by
edited by
What's the output of following code snippet?

Promise.resolve(1)

  .then((x) => x + 1)

  .then((x) => { throw new Error('My Error') })

  .catch(() => 1)

  .then((x) => x + 1)

  .then((x) => console.log(x))

  .catch(console.error)

1 Answer

0 votes
by

The short answer is 2 - however with this question I'd recommend asking the candidates to explain what will happen line-by-line to understand how they think. It should be something like this:

Related questions

+1 vote
asked May 30, 2020 in NodeJS Essentials by SakshiSharma
+1 vote
asked May 31, 2020 in NodeJS Essentials by Robindeniel
...