Created
September 24, 2018 12:11
-
-
Save lionxcr/0a52c485fe07462cc3fbbdab70166bf2 to your computer and use it in GitHub Desktop.
JS Bin// source https://jsbin.com/wuvogusolo
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
'use strict'; | |
var getCircunference = function getCircunference(radius) { | |
return Math.round(2 * 3.14 * radius); | |
}; | |
var promiseFunction = function promiseFunction(radius) { | |
return new Promise(function (resolve, reject) { | |
var response = getCircunference(radius); | |
if (!isNaN(response)) { | |
resolve(response); | |
} else { | |
reject('not a number'); | |
} | |
}); | |
}; | |
promiseFunction(90).then(function (sai) { | |
return console.log('Circunference is: ', sai); | |
})['catch'](function (error) { | |
return console.log('ERROR: ', error); | |
}); | |
promiseFunction('hellow').then(function (pablo) { | |
return console.log('Circunference is: ', pablo); | |
})['catch'](function (error) { | |
return console.log('ERROR: ', error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment