Async · Senior · about 20 minutes
Serial task queue
Implement createQueue(). queue.add(task) takes a function that returns a promise. Tasks run one at a time, in the order they were added. add returns a promise that settles as that task does. A task that fails does not stop the queue. In the tests a task is [addedAt, duration, value, fails]; the answer shows each task's outcome [status, value, time], when each task started, and the peak number running at once.
Start from
function createQueue() {
// Return { add(task) } that runs tasks one at a time.
}Hints and solution
Solve it in the app: its tests run without a year.
The hints, the solution and what an interviewer looks for opens with a year in the app. What a year includes