Promises & async/await Questions with Answers

21 practice questions on Promises & async/await (JavaScript) with answers and step-by-step solutions. Try 10 samples below, then practise all 21 free in the AptiNest app.

Sample questions

Question 1Easy

Which are the three states of a JavaScript Promise?

  1. waiting, running, completed
  2. pending, fulfilled, rejected
  3. created, resolved, cancelled
  4. started, succeeded, errored

Answer: B. pending, fulfilled, rejected

Explanation

A promise starts as pending and settles once, either fulfilled with a value or rejected with a reason.

Step-by-step solution

  1. A Promise represents the eventual result of an asynchronous operation.
  2. It starts in the 'pending' state, meaning the operation hasn't finished yet.
  3. It then settles exactly once, moving either to 'fulfilled' (success, with a resulting value) or 'rejected' (failure, with a reason) - and can never change state again after that.

Why the other options are wrong

  • A. "waiting, running, completed" is not the actual terminology JavaScript Promises use for their states.
  • C. "created, resolved, cancelled" doesn't match Promise terminology either; notably, Promises have no built-in 'cancelled' state.
  • D. "started, succeeded, errored" is close in spirit but doesn't use the actual specified Promise state names.

Tip: Memorise the three exact Promise states: pending, fulfilled, rejected - these specific words are what documentation and APIs (like Promise.allSettled) actually use.

Question 2Easy

What is the output?

Promise.resolve(1)
  .then(v => v + 1)
  .then(v => console.log(v));
  1. 1
  2. undefined
  3. Promise { 2 }
  4. 2

Answer: D. 2

Explanation

The first then returns 2, which is passed to the second then and logged.

Step-by-step solution

  1. resolve(1) -> v = 1.
  2. First then returns 2.
  3. Second then logs 2.

Why the other options are wrong

  • A. Each then receives the previous return value.
  • B. The first then returns a value.
  • C. The value is unwrapped before the second then.

Question 3Easy

What is the output?

Promise.reject(new Error('x'))
  .catch(e => console.log('caught', e.message))
  .then(() => console.log('after'));
  1. caught, x
  2. after
  3. caught, x, after
  4. after, caught, x

Answer: C. caught, x, after

Explanation

catch handles the rejection and returns normally, so the chain continues with "after".

Step-by-step solution

  1. The rejection goes to catch.
  2. catch returns undefined, so the chain resolves.
  3. Next then prints after.

Why the other options are wrong

  • A. The chain continues after a handled rejection.
  • B. The catch handler runs first.
  • D. catch runs before the later then.

Question 4Easy

What are the three states of a Promise?

  1. Waiting, running, finished
  2. Created, resolved, closed
  3. Pending, fulfilled, rejected
  4. Pending, success, error

Answer: C. Pending, fulfilled, rejected

Explanation

A promise starts pending and settles once, either fulfilled with a value or rejected with a reason.

Step-by-step solution

  1. Starts pending.
  2. Settles to fulfilled or rejected, once.

Why the other options are wrong

  • A. These are not Promise state names.
  • B. There is no closed state.
  • D. The states are fulfilled and rejected.

Question 5Medium

What is the output?

Promise.race([
  new Promise(r => setTimeout(() => r('slow'), 20)),
  new Promise(r => setTimeout(() => r('fast'), 5))
]).then(console.log);
  1. slow
  2. ['slow', 'fast']
  3. fast
  4. fast, slow

Answer: C. fast

Explanation

Promise.race settles with whichever promise settles first, here the 5 ms one.

Step-by-step solution

  1. Two timers: 20 ms and 5 ms.
  2. The faster settles first.
  3. race resolves with "fast".

Why the other options are wrong

  • A. race settles with the first promise to settle.
  • B. race returns a single value.
  • D. race resolves only once.

Question 6Medium

What is the output?

Promise.all([1, Promise.resolve(2), 3]).then(v => console.log(v.join()));
  1. 1,2,3
  2. 1,[object Promise],3
  3. 2
  4. 3

Answer: A. 1,2,3

Explanation

Promise.all accepts non-promise values too (they are treated as already resolved) and resolves with all results in input order.

Step-by-step solution

  1. Promise.all() waits for ALL the promises (or values) in its input array to settle, then resolves with an array of all their results, in the same order as the input.
  2. It also accepts plain, non-promise values mixed in with actual promises - these are simply treated as already-resolved values.
  3. Here, [1, Promise.resolve(2), 3] resolves to [1, 2, 3], and .join() turns that array into the comma-separated string "1,2,3".

Why the other options are wrong

  • B. "1,[object Promise],3" would be the result only if Promise.all failed to 'unwrap' the Promise.resolve(2) entry, but Promise.all specifically resolves each entry to its underlying value before combining them.
  • C. 2 alone would suggest only the Promise.resolve(2) entry mattered, but Promise.all preserves and returns ALL entries, in their original order, not just the promise-typed ones.
  • D. 3 alone similarly ignores that Promise.all returns the full array of all results, not just the last value.

Tip: Promise.all() preserves input order in its results, regardless of which promises actually settle first.

Question 7Medium

What is the output?

async function f() {
  try {
    await Promise.reject(new Error('bad'));
  } catch (e) {
    return 'handled ' + e.message;
  } finally {
    console.log('cleanup');
  }
}
f().then(console.log);
  1. handled bad, cleanup
  2. cleanup
  3. cleanup, bad
  4. cleanup, handled bad

Answer: D. cleanup, handled bad

Explanation

await throws on rejection, catch returns a string, finally logs cleanup first, then the promise resolves and then logs.

Step-by-step solution

  1. await throws the error.
  2. catch returns the string.
  3. finally prints cleanup.
  4. then logs the returned value.

Why the other options are wrong

  • A. finally runs before the promise resolves.
  • B. The returned string is logged too.
  • C. The catch block returns a string, not the message.

Question 8Medium

What is the output?

Promise.resolve(1)
  .then(v => { throw new Error('boom'); })
  .then(() => console.log('A'))
  .catch(() => console.log('B'))
  .then(() => console.log('C'));
  1. A, B, C
  2. B
  3. B, C
  4. A, C

Answer: C. B, C

Explanation

The throw rejects the chain, skipping the then that prints A; catch prints B and resolves, so C prints.

Step-by-step solution

  1. Throw rejects the promise.
  2. Then A is skipped.
  3. catch prints B, recovering.
  4. Then C prints.

Why the other options are wrong

  • A. A is skipped because a rejection bypasses plain then handlers.
  • B. The final then still runs after a handled error.
  • D. The rejection reaches catch.

Question 9Hard

What is the output?

new Promise((resolve, reject) => {
  resolve('first');
  reject(new Error('second'));
  resolve('third');
}).then(console.log, e => console.log('err'));
  1. err
  2. first
  3. third
  4. first, err

Answer: B. first

Explanation

A promise can settle only once; the later reject and resolve calls are ignored.

Step-by-step solution

  1. resolve("first") settles the promise.
  2. Later calls are ignored.
  3. then logs "first".

Why the other options are wrong

  • A. Only the first settle call has any effect.
  • C. Later calls are ignored.
  • D. A promise settles once.

Question 10Hard

You need the results of several independent requests, and one failure must not discard the others. Which combinator fits best?

  1. Promise.allSettled
  2. Promise.race
  3. Promise.any
  4. Promise.all

Answer: A. Promise.allSettled

Explanation

Promise.allSettled waits for every promise and reports each outcome as {status, value} or {status, reason}. Promise.all rejects as soon as any one rejects.

Step-by-step solution

  1. You need the outcome of EVERY promise, successful or not, without one failure wiping out the rest of the results.
  2. Promise.all() would reject immediately as soon as any single promise rejects, discarding the results of the others - not what's wanted here.
  3. Promise.allSettled() instead waits for every promise to settle (whether fulfilled or rejected) and gives you an array describing each individual outcome.

Why the other options are wrong

  • B. Promise.race() settles as soon as the FIRST promise settles (ignoring all the rest entirely), which doesn't give you every result.
  • C. Promise.any() resolves with the first SUCCESS and ignores failures, but it still doesn't give you every individual promise's own outcome.
  • D. Promise.all() rejects as a whole the moment any single promise rejects, discarding the other, possibly successful, results - the opposite of what's needed here.

Tip: Need 'all results, failures included, nothing discarded'? Use Promise.allSettled(), not Promise.all().

Practise all 21 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all JavaScript topics · All topics