Promise Basic Structure

by Jacob King

JavaScript

let myPromise = new Promise(function(resolve, reject) {
  // Simulate an asynchronous operation like an API call or file reading
  let success = true; // Simulate a successful operation

  if (success) {
    resolve("The operation was successful!");
  } else {
    reject("There was an error with the operation.");
  }
});