Skip to content

Instantly share code, notes, and snippets.

@lionxcr
Created September 24, 2018 12:11
Show Gist options
  • Save lionxcr/0a52c485fe07462cc3fbbdab70166bf2 to your computer and use it in GitHub Desktop.
Save lionxcr/0a52c485fe07462cc3fbbdab70166bf2 to your computer and use it in GitHub Desktop.
'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