0
0
Node.jsframework~10 mins

Promise.race and Promise.allSettled in Node.js - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to use Promise.race to get the first resolved promise.

Node.js
Promise.[1]([promise1, promise2]).then(result => console.log(result));
Drag options to blanks, or click blank then click option'
AallSettled
Ball
Crace
Dany
Attempts:
3 left
💡 Hint
Common Mistakes
Using Promise.all instead of Promise.race, which waits for all promises.
Using Promise.allSettled which waits for all promises to settle.
2fill in blank
medium

Complete the code to use Promise.allSettled to wait for all promises to settle.

Node.js
Promise.[1]([promiseA, promiseB]).then(results => console.log(results));
Drag options to blanks, or click blank then click option'
Aall
Brace
Cany
DallSettled
Attempts:
3 left
💡 Hint
Common Mistakes
Using Promise.all which rejects immediately if any promise rejects.
Using Promise.race which returns the first settled promise only.
3fill in blank
hard

Fix the error in the code to correctly handle the first settled promise.

Node.js
Promise.[1]([p1, p2, p3]).then(value => console.log('First:', value));
Drag options to blanks, or click blank then click option'
AallSettled
Brace
Call
Dany
Attempts:
3 left
💡 Hint
Common Mistakes
Using Promise.all which waits for all promises to resolve.
Using Promise.allSettled which returns all results, not just the first.
4fill in blank
hard

Fill both blanks to create a Promise.allSettled usage that logs each promise's status and value.

Node.js
Promise.[1]([pA, pB]).then(results => {
  results.forEach(result => {
    console.log(result.[2] + ':', result.value || result.reason);
  });
});
Drag options to blanks, or click blank then click option'
AallSettled
Brace
Cstatus
Dall
Attempts:
3 left
💡 Hint
Common Mistakes
Using Promise.all which rejects on first failure.
Trying to access 'value' without checking status.
5fill in blank
hard

Fill all three blanks to create a Promise.race that handles the first promise and logs its result or error.

Node.js
Promise.[1]([pX, pY, pZ])
  .then(result => console.log('Resolved:', result))
  .catch(error => console.log('Rejected:', error));
Drag options to blanks, or click blank then click option'
Arace
BallSettled
Call
Dany
Attempts:
3 left
💡 Hint
Common Mistakes
Using Promise.all which waits for all promises.
Not handling rejection with catch.