Published on January 26, 2024By DeveloperBreeze
// Function that returns a Promise
function customPromise() {
return new Promise((resolve, reject) => {
// Simulate asynchronous operation with a setTimeout
setTimeout(() => {
// Resolve the promise with a message after 1000 milliseconds
resolve('Promise resolved!');
}, 1000);
});
}
// Call the function and handle the resolved promise
customPromise().then(result => {
console.log(result); // Output: Promise resolved!
});
Comments
Please log in to leave a comment.