PromiseAll = function(promise){
return new Promise((resolve,reject)=>{
let res = []
let len = promise.length
let con = 0
for(let i=0;i<len;i++){
Promise.resolve(promise[i]).then(data=>{
res[i] = data
if (i + 1 == len){
resolve(res)
}
}).catch(err=>{
throw(err)
})
}
})
}
const promise1 = Promise.resolve(3);
const promise2 = 42;
const promise3 = new Promise((resolve, reject) => {
setTimeout(resolve, 100, 'foo');
});
PromiseAll([promise1, promise2, promise3]).then((values) => {
console.log(values);
});
console