Wait for the booking

Starting a save and finishing a save happen at different times.

your task

Keep both lines and add one word. The check must print the stored status after each save finishes.

saveBooking starts saving a new status. It returns a promise that tells you when the save finishes. The starter prints stored while it still holds the old status.

Starter code
or press Ctrl EnterNot run yet

cases

Not run yetConfirm a held booking

Expected output

1stored: confirmed
See the input and the code for this case
let stored = "held";
const newStatus = "confirmed";
function saveBooking(status) {
  return new Promise((resolve) => {
    setTimeout(() => {
      stored = status;
      resolve();
    }, 20);
  });
}
Not run yetCancel a confirmed booking

Expected output

1stored: cancelled
See the input and the code for this case
let stored = "confirmed";
const newStatus = "cancelled";
function saveBooking(status) {
  return new Promise((resolve) => {
    setTimeout(() => {
      stored = status;
      resolve();
    }, 20);
  });
}