Select Git revision
-
Harshith Karkera authoredHarshith Karkera authored
index.js 400 B
// Creating a Promise
const myPromise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve("Hello World");
}, 1000); // Simulating an async operation with setTimeout
});
// Calling the Promise
myPromise
.then((message) => {
console.log("Message:", message); // Display the message
})
.catch((error) => {
console.error("Error:", error);
});