Computer scienceProgramming languagesJavaScriptAdvanced featuresPromise

"then", "catch" and "finally" methods

Still loading...

Report a typo

Complete the function loader according to the following cases:

  • In case of success, show the message: The info has loaded.
  • In case of failure, show the message: Please, try again later.
  • In any case, show the message: Hello, Mr. Smith!

Sample Input 1:

true

Sample Output 1:

The info has loaded.
Hello, Mr. Smith!
Write a program in JavaScript
function loader(value) {
const promise = new Promise(function(resolve, reject){
if (value === "true"){
resolve();
} else {
reject();
}
});

return promise;
}
___

Create a free account to access the full topic