Promises & Callbacks — Series 3

Preview — 3 of 10 questions

What is logged?

javascript
new Promise(() => {
  throw new Error('executor failed');
})
  .then(() => console.log('then'))
  .catch((err) => console.log('caught:', err.message));
Athen
Bcaught: executor failed
CNothing — the error escapes the promise and crashes.
Dthen then caught: executor failed

What is logged, in order?

javascript
Promise.reject(new Error('nope'))
  .finally(() => console.log('cleanup'))
  .catch((err) => console.log('caught:', err.message));
Acaught: nope only
Bcleanup only
Ccaught: nope, then cleanup
Dcleanup, then caught: nope

What is logged?

javascript
Promise.resolve(1)
  .then((v) => v + 1)
  .then((v) => {
    console.log(v);
  })
  .then((v) => console.log(v));
A2 then undefined
B2 then 2
C1 then 2
D2 only

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.