Wrap setTimeout in a promise to delay logging a message.
Output:
createPromise
over 1 year agoCreate a promise that resolves with the message 'Done' and log it.
usePromise
over 1 year agoUse a promise to simulate loading user data and then log the result.
promiseFinally
over 1 year agoUse .finally() to log 'Finished loading' after the promise is resolved.
chainPromises
over 1 year agoChain multiple .then() methods to transform a number from 2 to 7.
handleError
over 1 year agoCatch an error if a promise is rejected and log the error message.
timeoutPromise
over 1 year agoWrap setTimeout in a promise to delay logging a message.
constructPromise
over 1 year agoConstruct a promise that rejects if the input is less than 5.
loadAllData
over 1 year agoUse Promise.all to wait for two async operations.
fastestPromise
over 1 year agoUse Promise.race to log the result of the fastest-resolving promise.