As reported: Intuit senior frontend engineer, technical phone interview (2025), JavaScript question: function
A()returns 2 after 2 seconds andB()returns 3 after 3 seconds; return their sum by running them in parallel (3 seconds in total) and sequentially (5 seconds in total).
Two asynchronous functions are given:
A()resolves to2after 2 seconds.B()resolves to3after 3 seconds.
Write:
sumParallel()— returns (a promise of)A() + B()=5, finishing after about 3 seconds.sumSequential()— returns the same sum, but runsBonly afterAhas finished, so it takes about 5 seconds.
Implement A and B too (with setTimeout).