Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '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);
- });
Add Comment
Please, Sign In to add comment