Write a function `fastest(promises)` that returns a promise resolving/rejecting with the first settled promise.
Problem Statement
Write a function `fastest(promises)` that returns a promise resolving/rejecting with the first settled promise.
Complexity
Time Complexity: -
Space Complexity: -
Hints
š” Hint 1:
Promise.race() resolves or rejects as soon as any promise settles first.
š” Hint 2:
The "winner" determines whether race resolves or rejects.
š” Hint 3:
return Promise.race(promises);
ā
Solution:
```javascript
function fastest(promises) {
return Promise.race(promises);
}
```