Guest User

Untitled

a guest
Sep 24th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. 'use strict';
  2.  
  3. var getCircunference = function getCircunference(radius) {
  4. return Math.round(2 * 3.14 * radius);
  5. };
  6.  
  7. var promiseFunction = function promiseFunction(radius) {
  8. return new Promise(function (resolve, reject) {
  9. var response = getCircunference(radius);
  10. if (!isNaN(response)) {
  11. resolve(response);
  12. } else {
  13. reject('not a number');
  14. }
  15. });
  16. };
  17.  
  18. promiseFunction(90).then(function (sai) {
  19. return console.log('Circunference is: ', sai);
  20. })['catch'](function (error) {
  21. return console.log('ERROR: ', error);
  22. });
  23.  
  24. promiseFunction('hellow').then(function (pablo) {
  25. return console.log('Circunference is: ', pablo);
  26. })['catch'](function (error) {
  27. return console.log('ERROR: ', error);
  28. });
Add Comment
Please, Sign In to add comment