Created
January 1, 2021 16:26
-
-
Save shahab570/faf13726df7db2c92cd8e5a97fc0478d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let take_bath = new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve("I have finished my bath"); | |
}, 5000); | |
}); | |
let eat = new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve("I have finished eating"); | |
}, 3000); | |
}); | |
Promise.race([take_bath,eat]).then((value) => { | |
console.log(value); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment