Skip to content
Snippets Groups Projects
Commit ddafcc92 authored by Harshith Karkera's avatar Harshith Karkera
Browse files

Initial commit: promise implementation added

parents
Branches main
No related tags found
1 merge request!1Initial commit: promise implementation added
index.js 0 → 100644
// 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);
});
{
"name": "my-node",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment