Easy javaScript Solution
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

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

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```javascript []
/**
 * @param {Array<Function>} functions
 * @return {Promise<any>}
 */
var promiseAll = function(functions) {
    return new Promise((res, rej) => {
        let arr = Array(functions.length);  // Array to store results
        let waitinglen = functions.length; // Track number of unresolved promises

        for(let i = 0; i < functions.length; i++) {
            functions[i]()  // Invoke the function to get the promise
            .then((result) => {
                arr[i] = result;  // Store result at correct index
                waitinglen--;      // Decrease count of pending promises

                if (waitinglen === 0) res(arr);  // If all are resolved, return results
            })
            .catch(rej);  // If any promise rejects, reject the main promise
        }
    });
};


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