Created
June 30, 2023 17:14
-
-
Save onosendi/866c511ada9575aeef6f0cccc6da8a58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const errors = []; | |
const ress = []; | |
const fn = (x) => new Promise((resolve) => { | |
if (x === 0) { | |
errors.push('Equals 0'); | |
// reject(new Error('Error: equals 0')); | |
} else { | |
// resolve(`Resolved: ${x}`); | |
ress.push(`Equals ${x}`); | |
} | |
resolve(); | |
}); | |
const arr = [ | |
fn(1), | |
fn(2), | |
fn(0), | |
fn(3), | |
fn(0), | |
]; | |
Promise | |
.all(arr) | |
.then(() => { | |
console.log(ress); | |
console.log(errors); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment