Execute Asynchronous Functions in Parallel
Intuition
array of function
iterate through each and wrap each in Promise [which was wrong as it was already given that functions was array of asynchronous func
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

- array of function
- iterate through each and wrap each in Promise [which was wrong as it was already given that functions was array of asynchronous functions, so Promise is there already.]
- mimic Promise.all





# Approach
<!-- Describe your approach to solving the problem. -->
Breaking down the question first and writing down the process step by step in normal language.

Adding code to the written to-dos. 

Reading comments for hints while avoiding the solutions posted.

Getting the help of chartGPT in pointing out where I am wrong and going back and forth with fundamental concepts to "argue" with GPT.


# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
 $$O(n)$$

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
 $$O(n)$$
# Code
```javascript []
/**
 * @param {Array<Function>} functions
 * @return {Promise<any>}
 */
var promiseAll = function(functions) {

    return new Promise((resolve,reject)=>{
        let arrayThing = [];
        let countPromises = 0

        for(let i=0; i<functions.length;i++){
            const promise = functions[i]()
        promise
        .then(result=>{arrayThing[i]=result;
                countPromises++
        if(functions.length===countPromises) {
            resolve(arrayThing)
        }}
        )
        .catch(error=>reject(error))

    }
    })

}





/**
 * const promise = promiseAll([() => new Promise(res => res(42))])
 * promise.then(console.log); // [42]
 */
```
['JavaScript']