Skip to content

Instantly share code, notes, and snippets.

View cyberrrnaut's full-sized avatar
🎯
Focusing

Soumyendu Das cyberrrnaut

🎯
Focusing
View GitHub Profile
function myAsyncFunction() {
return new Promise((resolve, reject) => {
setTimeout(() => {
const randomNumber = Math.random();
if (randomNumber > 0.5) {
resolve(randomNumber); // Resolve the promise with a value
} else {
reject(new Error("Random number is less than 0.5")); // Reject the promise with an error
}
}, 1000);