Solved !
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```javascript []\n/**\n * @param {Array<Function>} functions\n * @return {Promise<any>}\n */\nfunction promiseAll(functions) {\n    return new Promise((resolve, reject) => {\n        const results = new Array(functions.length);  // Array to store results in original order\n        let resolvedCount = 0;  // Counter to track resolved promises\n\n        functions.forEach((func, index) => {\n            func()  // Call each function to get its promise\n                .then(value => {\n                    results[index] = value;  // Store result in the correct order\n                    resolvedCount++;  // Increment resolved count\n\n                    // If all promises have resolved, resolve the outer promise with results\n                    if (resolvedCount === functions.length) {\n                        resolve(results);\n                    }\n                })\n                .catch(error => {\n                    reject(error);  // Reject immediately on the first error\n                });\n        });\n    });\n}\n\n\n/**\n * const promise = promiseAll([() => new Promise(res => res(42))])\n * promise.then(console.log); // [42]\n */\n```
['JavaScript']