Implement a function promiseRace(promises) that behaves like Promise.race().
The function should:
Examples
const p1 = new Promise((res) => setTimeout(() => res(1), 100)); const p2 = new Promise((res) => setTimeout(() => res(2), 50)); promiseRace([p1, p2]).then(console.log); // 2 const p3 = Promise.reject('error'); promiseRace([p3, p1]).catch(console.log); // 'error'
JavaScript Function
No test results yet
Click "Run" to execute tests