Complete the code to use Promise.race to get the first resolved promise.
Promise.[1]([promise1, promise2]).then(result => console.log(result));Promise.race returns a promise that resolves or rejects as soon as one of the promises in the iterable resolves or rejects.
Complete the code to use Promise.allSettled to wait for all promises to settle.
Promise.[1]([promiseA, promiseB]).then(results => console.log(results));Promise.allSettled waits for all promises to settle, regardless of resolve or reject, and returns their results.
Fix the error in the code to correctly handle the first settled promise.
Promise.[1]([p1, p2, p3]).then(value => console.log('First:', value));
To get the first settled promise's value, use Promise.race. Other methods behave differently.
Fill both blanks to create a Promise.allSettled usage that logs each promise's status and value.
Promise.[1]([pA, pB]).then(results => { results.forEach(result => { console.log(result.[2] + ':', result.value || result.reason); }); });
Promise.allSettled returns an array of objects with status and either value or reason. Logging status shows if each promise fulfilled or rejected.
Fill all three blanks to create a Promise.race that handles the first promise and logs its result or error.
Promise.[1]([pX, pY, pZ]) .then(result => console.log('Resolved:', result)) .catch(error => console.log('Rejected:', error));
Promise.race returns a promise that settles as soon as one of the promises settles, either resolved or rejected. The then handles success, and catch handles rejection.