TryBugHunt
All collections
⏳Asynchronous Code ~30 mins

Async Nightmares

Promises, race conditions, and forgotten awaits

The asynchronous bugs that silently swallow data: un-awaited promises, forEach loops with async callbacks, and race conditions.

JavaScriptHard5 Challenges

Your Progress

0 of 5 completed

Start Collection

Challenges in this collection

  1. 1

    Doubling with forEach returns an empty list

    doubleAll(nums) doubles every number with fetchDouble, which takes a moment, and returns the results. Example: await doubleAll([1, 2, 3]) → [2, 4, 6].

    hard
  2. 2

    Total shows "[object Promise]" instead of 6

    sumDelayed(nums) adds up numbers that each arrive after a short delay. Example: await sumDelayed([1, 2, 3]) → 6.

    medium
  3. 3

    Word lengths come back as promises, not numbers

    wordLengths(words) returns the length of each word. Example: await wordLengths(["abc", "defg"]) → [3, 4].

    medium
  4. 4

    Adding 4 votes at once keeps only the last

    tallyVotes(votes) adds up every vote. The votes are counted at the same time with Promise.all. Example: await tallyVotes([1, 2, 3, 4]) → 10.

    hard
  5. 5

    3 people book the last seat

    bookSeats(n) sends n booking requests at the same time for 1 remaining seat, and returns how many bookings succeeded. It should never be more than 1. Example: await bookSeats(3) → 1.

    hard

More collections to explore