🗓️ Daily LeetCoding Challenge Day 19|| 🔥 JS SOL
\n# Code\n\nvar promiseAll = async function(functions) {\n    return new Promise((resolve, reject) => {\n        let results = [];\n        functions.forEach(fn
\n# Code\n```\nvar promiseAll = async function(functions) {\n    return new Promise((resolve, reject) => {\n        let results = [];\n        functions.forEach(fn => {\n            fn()\n            .then(val => results.push(val))\n            .catch(reason => reject(reason));\n        });\n        resolve(results);\n    })};\n\nvar promiseAll = async function(functions) {\n    return new Promise((resolve,reject)=>{\n        if(functions.length === 0) {\n            resolve([]);\n            return;\n        }\n        const arr=new Array(functions.length);\n        arr.fill(null);\n        let count=0\n        functions.forEach(async(fn,i)=>{\n            try{\n                arr[i]=await fn()\n                count++\n            \n                if(count===functions.length){\n                    resolve(arr);\n                }\n            }\n            catch(e){\n                reject(e);\n            }\n        \n        });\n    });\n};\n```
['JavaScript']