hi vietnam
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```typescript []\ntype Fn<T> = () => Promise<T>\nfunction promiseAll<T>(functions: Fn<T>[]): Promise<T[]> {\n    const results: any = [];\n    let count = 0;\n    const length = functions.length;\n    return new Promise((reslove, reject) => {\n        functions.forEach((element, index) => {\n            element()\n                .then((result) => {\n                    count++;\n                    results[index] = result;\n                    if (count === length) reslove(results);\n                })\n                .catch((error) => reject(error));\n        });\n    });\n}\n\n/**\n * const promise = promiseAll([() => new Promise(res => res(42))])\n * promise.then(console.log); // [42]\n */\n```
['TypeScript']