Skip to content

Instantly share code, notes, and snippets.

@deependhamecha
Last active January 11, 2022 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deependhamecha/4fcc30cede6b9d9542e4fd86b4f1cb67 to your computer and use it in GitHub Desktop.
Save deependhamecha/4fcc30cede6b9d9542e4fd86b4f1cb67 to your computer and use it in GitHub Desktop.
Promise Example
var fun = function(name) {
    var p = new Promise((resolve, reject) => {

        if(name=='Deepen') {
            resolve(`Congrats ${name}`);
        } else {
            reject('Fail');
        }
    });

    return p;
}

fun('Deepen').then(console.log).catch(console.log);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment