Change the hasDownloaded function by using .then or .then and .catch and display the texts passed to the resolve and reject functions in the console as arguments.
"then", "catch" and "finally" methods
Oops! We have a problem
Report a typo
Sample Input 1:
falseSample Output 1:
Oops! An error occursSample Input 2:
trueSample Output 2:
Now you can watch the video!Write a program in JavaScript
function hasDownloaded (value) {
const promise = new Promise(function(resolve, reject){
if (value === "true"){
resolve("Now you can watch the video!");
} else {
reject("Oops! An error occurs");
}
});
return promise
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.