-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPromises.js
More file actions
71 lines (55 loc) · 1.85 KB
/
Promises.js
File metadata and controls
71 lines (55 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// // Promise = An object that manages asynchronous operation.
// // wrap a promise Object around {asynchronous code}
// // "I promises to return a value."
// // PENDING -> RESOLVED OR REJECTED
// // new Promise(resolve,reject) => {asynchronous code}
// // DO THESE CHORES IN ORDER
// // 1.WALK THE DOG
// // 2.CLAEN THE DOG
// // 3.TAKE OUT THE TRASH
// function walkThedog() {
// return new Promise((resolve, reject) => {
// setTimeout(() => {
// const cleanKitchen = true;
// if (cleanKitchen) {
// resolve(`You take dog for a walk.`);
// }
// else {
// reject('you didnt clean the kitchen')
// }
// }, 1500)
// });
// }
// function cleanThedog() {
// return new Promise((resolve, reject) => {
// setTimeout(() => {
// const walkDog = true;
// if (walkDog) {
// resolve(`You clean the dog`);
// }
// else {
// reject('you didnt take dog for a walk')
// }
// }, 2500);
// });
// }
// function TakeOutTrash() {
// return new Promise((resolve, reject) => {
// setTimeout(() => {
// const taketrsh = true;
// if (taketrsh) {
// resolve(`You take out the t r ash .`);
// }
// else {
// reject('you didnt take out the trash')
// }
// }, 500)
// });
// }
// walkThedog().then(value => { console.log(value); return cleanThedog() })
// .then(value => { console.log(value); return TakeOutTrash() })
// .then(value => { console.log(value); return console.log('You finished the work') })
// .catch(Error => { console.error(Error); })
let a = 2
let b = "2"
console.log(b + a);