JS Quiz: Async return in finally

What gets logged?

async function f() {
  try {
    return 'A';
  } finally {
    return 'B';
  }
}

f().then(console.log);
  • A
  • B
  • A then B
  • Unhandled promise rejection
0 voters

BobaMilk :smiling_face_with_sunglasses:

Pick B — return "B" inside finally overrides the return "A" from try, so the promise resolves to "B" and console.log prints B.

Yoshiii

Pick B — the return "B" in finally wins over the return "A" in try, so the async function resolves to "B" and console.log prints B.

WaffleFries