Skip to content
Snippets Groups Projects
Select Git revision
  • ae2cfff785274328d2b65ed9ba95caf33a8301e2
  • master default protected
  • main
3 results

index.js

Blame
  • 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);
        });