function delay(ms, rejectPromise=false) {
return new Promise((resolve, reject) => setTimeout(()=>{
if(rejectPromise){
reject(`Delay promise (REJECT) - ${ms}`)
} else {
resolve(`Delay promise - ${ms}`)
}
}, ms));
}
const promises = [delay(5000), delay(1000), delay(2000)];
//const promisesOneRejection = [delay(5000), delay(1000), delay(2000, true)];
async function promiseAll(promises) {
// Write implementation here to resolve an array of promises passed in
// Documentation of Promise.all():
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all
}
promiseAll(promises)
.then((res)=>{
console.log(res)
})
.catch((err)=>{
console.log(err)
})