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.
Run code runs your code once for each case. It compares what your code prints with the expected output.
Starter code
or press Ctrl EnterNot run yet
cases
Not run yetConfirm a held booking
Expected output
1
stored: confirmedSee 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
1
stored: cancelledSee 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);
});
}