Promise Chaining Lab

Medium
0.0% Acceptance

In this lab, you will be working on creating and chaining promises. Promises play an important role in JavaScript for handling asynchronous operations like API calls, timers and file operations. A Promise is an object representing the eventual completion (or failure) of an asynchronous operation and its resulting value. A Promise is in one of the 3 states:

  1. Pending: The initial state, neither fulfilled nor rejected.
  2. Fulfilled: The operation completed successfully, and the promise has a resulting value.
  3. Rejected: The operation failed, and the promise has a reason for the failure.

You will be given a set of tasks that focus on creating and chaining promises. The main goals are to understand how to create a basic promise, chain promises using .then() and .catch() methods, use the async/await syntax to handle promises, and properly handle errors using a try/catch block.

Challenges

  1. Create a basic promise that resolves with a string value.
  2. Chain a .then() method to a promise.
  3. Chain a .catch() method to a promise.
  4. Combine both .then() and .catch() methods for error handling.
  5. Use async/await to handle a promise.
  6. Handle errors using a try/catch block with async/await.