Last active
March 28, 2021 22:46
-
-
Save dd701116/8f4f2648fb0eecb3e08416aa403b9b24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// An asynchronous function | |
async function theAsynchronousMethod() { | |
return Math.floor(Math.random() * Math.floor(6)); | |
} | |
// Another asynchronous function | |
async function anotherAsynchronousMethod() { | |
// Wait the response | |
let dice = await theAsynchronousMethod(); | |
// And continue | |
if (dice>=3) { | |
console.log("Yes, I'll do it !"); | |
}else{ | |
throw new Error("Nope, drop it !"); | |
} | |
} | |
try{ | |
anotherAsynchronousMethod(); | |
} catch (e) { | |
console.error(e.message); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment