Problem Statement
Which statement about Promise.all and Promise.race is correct?
Explanation
Promise.all resolves to an array of results if all promises resolve, and rejects on the first rejection.
Promise.race settles as soon as any input promise settles (resolve or reject).
Code Solution
SolutionRead Only
Promise.all([p1, p2])
.then(vals => console.log(vals))
.catch(err => console.error('ALL reject', err));
Promise.race([p1, p2])
.then(val => console.log('RACE', val))
.catch(err => console.error('RACE reject', err));Practice Sets
This question appears in the following practice sets:
