1function promise(){
2 return new Promise((resolve, reject) =>{
3 // Code //
4 resolve("Resolved!"); // "Returns" resolved
5 reject("Rejected!"); // "Returns" rejected
6 // Code //
7 }):
8};
9
10// Usage //
11promise()
12 .then(res => {
13 console.log(res)
14 }) // Done when resolved //
15
16 .catch(err => {
17 console.log(err)
18 }) // Done when Rejected //
19