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