Implement the runSequentially function, that should return a Promise that resolves to an array of results. The first argument to runSequentially, functions, is an array of functions where each function from the functions array returns a Promise. The functions should be run sequentially, one after another. If any of the functions throw an exception, the runSequentially should reject the Promise. The first element in the result array should be the result of the first function from the functions array, the second element in the result array should be the result of the second function from the functions array, and so on.
1
[2, 3]
The above mentioned example is a sample test case for your understanding. The program will be tested on other secret test cases in the backend. Make sure you click the SUBMIT button to save and submit your answer.