Implement Promise.any
MediumImplement promiseAny(promises) function that works like native Promise.any().
Requirements:
- Resolves with the first successful promise
- Ignores rejected promises until first successful one
- If all promises rejected - rejects with error
- Returns result of first successful promise (not array)
- DO NOT use built-in Promise.any()
Example:
const result = await promiseAny([
Promise.reject('error1'),
Promise.resolve('success!'),
Promise.reject('error2')
]);
// result = 'success!'JavaScript•UTF-8
Run your code to see results.
Click the Run button above
Mobile view - please use desktop for better experience