loading
open in
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function promiseNumberCheck(argument) { 
     if(isNaN(argument)) {
       return Promise.reject(argument + " is not a number"); 
     } else { 
       return Promise.resolve("We got number " + argument);
     }
}
let test1 = promiseNumberCheck(1);
let test2 = promiseNumberCheck("nothing");

test1.then(function(result) {
	console.log(result);
}, function(error) { 
  console.log(error);
});

test2.then(function(result) {
	console.log(result);
}).catch(function(error) { 
   console.log(error);
});
Native Browser JavaScript