Created
December 6, 2019 14:35
-
-
Save kcoyner/3b22fe68efeda3617f88f8f8d565424b 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
function getMoneyBack(money) { | |
money = String(money) // force the rejectkk | |
return new Promise((resolve, reject) => { | |
if (typeof money !== 'number') { | |
reject(new Error('money is not a number')) | |
} else { | |
resolve(money) | |
} | |
}) | |
} | |
getMoneyBack(1200).then((money) => { | |
console.log(money) | |
}) | |
.catch(error => { | |
console.error(error) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment