This question was asked in Meta’s frontend interview.

The problem statement reads as – Implement an engine that process async callbacks using JavaScript. Your task is to provide implementation of the class QueueCallbacks to meet all the condition:

Constructor requirements

You should provide the implementation of the constructor and process methods, Do not change the names of these methods or the number of arguments they receive.

Process method requirements

The process method receive a single async function that should be executes by following the algorithm described below:

Solution

If you read the problem statements carefully you would be implement the algorithm step by step. This is how we are going to solve this: