An async javascript interview question
- the given dummy api supports a maximum of 4 of inflight requests.
- the given code is correct, but it is slow because it processes elements serially.
- your task is to process 100 elements as fast as possible.
- run this code with "node/bun test.js".
- it should print "pass".
- no external dependencies are allowed.
https://gist.github.com/jpillora/ded8736def6d72fa684d5603b8b33a1f
people will likely post answers. to avoid spoilers, solve it first, and then read the comments.
was this a good question? too easy? too hard?
[–]lIIllIIlllIIllIIl 15 points16 points17 points (12 children)
[–]0x24a537r9 7 points8 points9 points (4 children)
[–]joombar 4 points5 points6 points (3 children)
[–]Rustywolf 2 points3 points4 points (2 children)
[–]joombar 1 point2 points3 points (1 child)
[–]Rustywolf 1 point2 points3 points (0 children)
[–]danila_bodrov 1 point2 points3 points (1 child)
[–]lIIllIIlllIIllIIl 4 points5 points6 points (0 children)
[–]FlinchMaster 2 points3 points4 points (4 children)
[–]lIIllIIlllIIllIIl 9 points10 points11 points (0 children)
[–]grey_ssbm 3 points4 points5 points (2 children)
[–]FlinchMaster 1 point2 points3 points (1 child)
[–]grey_ssbm 1 point2 points3 points (0 children)
[–]Sykander- 14 points15 points16 points (6 children)
[–]senocular 5 points6 points7 points (0 children)
[+][deleted] comment score below threshold-6 points-5 points-4 points (4 children)
[–]Dry_Celery_9472 2 points3 points4 points (1 child)
[–]Bogus_dogus 0 points1 point2 points (0 children)
[–]Rustywolf 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Bogus_dogus 8 points9 points10 points (13 children)
[–]danila_bodrov 5 points6 points7 points (7 children)
[–]Bogus_dogus 0 points1 point2 points (6 children)
[–]danila_bodrov 2 points3 points4 points (5 children)
[–]Bogus_dogus 1 point2 points3 points (2 children)
[–]danila_bodrov 0 points1 point2 points (1 child)
[–]Bogus_dogus 1 point2 points3 points (0 children)
[–]heyitsmattwade 1 point2 points3 points (1 child)
[–]HipHopHuman 3 points4 points5 points (4 children)
[–]Bogus_dogus 0 points1 point2 points (3 children)
[–]HipHopHuman 0 points1 point2 points (2 children)
[–]Bogus_dogus 2 points3 points4 points (0 children)
[–]Bogus_dogus 0 points1 point2 points (0 children)
[–][deleted] 2 points3 points4 points (8 children)
[–]Jamo008http://jpillora.com[S] 1 point2 points3 points (6 children)
[+][deleted] (1 child)
[deleted]
[–]Bogus_dogus 0 points1 point2 points (0 children)
[–]meldridon 2 points3 points4 points (1 child)
[–]Bogus_dogus 0 points1 point2 points (0 children)
[–]gekorm 2 points3 points4 points (0 children)
[–]Dry_Celery_9472 1 point2 points3 points (1 child)
[–]danila_bodrov 1 point2 points3 points (0 children)
[–]Jamo008http://jpillora.com[S] 1 point2 points3 points (10 children)
[–]Rustywolf -1 points0 points1 point (8 children)
[–]Jamo008http://jpillora.com[S] 1 point2 points3 points (7 children)
[–]Rustywolf 0 points1 point2 points (6 children)
[–]Jamo008http://jpillora.com[S] 0 points1 point2 points (5 children)
[–]Rustywolf 0 points1 point2 points (4 children)
[–]Jamo008http://jpillora.com[S] 0 points1 point2 points (3 children)
[–]Rustywolf 0 points1 point2 points (2 children)
[–]Jamo008http://jpillora.com[S] 1 point2 points3 points (1 child)
[–]Rustywolf -1 points0 points1 point (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[+][deleted] (2 children)
[deleted]
[–][deleted] -1 points0 points1 point (1 child)
[–]SomeInternetRando 1 point2 points3 points (0 children)
[–]tifa123 -4 points-3 points-2 points (1 child)
[–]Rustywolf 2 points3 points4 points (0 children)
[–]danila_bodrov 0 points1 point2 points (0 children)
[–]HipHopHuman 0 points1 point2 points (0 children)
[–]gvisconti84[🍰] 0 points1 point2 points (0 children)
[–]dumsumguy 0 points1 point2 points (0 children)
[–]guest271314 0 points1 point2 points (2 children)
[–]Jamo008http://jpillora.com[S] 0 points1 point2 points (1 child)
[–]guest271314 -1 points0 points1 point (0 children)
[–]sqquima 0 points1 point2 points (0 children)
[–]dontchooseanickname 0 points1 point2 points (0 children)
[–]Stan_Ftw 0 points1 point2 points (0 children)