-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassign14.js
57 lines (45 loc) · 1.06 KB
/
assign14.js
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
const blog=[{title:"Blog1"}];
const lastTime=[];
function createPost()
{
return new Promise((res,rej)=>{
setTimeout(()=>{
blog.push({title:"Blog After"})
res();
},2000)
})
}
function lastActivityTime()
{
return new Promise((res,rej)=>{
setTimeout(()=>{
let createdAt=new Date().getTime();
lastTime.push({lastActivity: createdAt});
res("Last Activity Time="+createdAt);
},1000)
})
}
function deletePost()
{
return new Promise((res,rej)=>{
setTimeout(()=>{
let post=blog.pop();
res(post);
},2000)
})
}
function userActivity()
{
Promise.all([createPost(),lastActivityTime()]).then(([cPost,lTime])=>{
console.log(lTime);
}).catch(err=>console.log(err))
}
function userDeleteActivity()
{
Promise.all([deletePost(),lastActivityTime()]).then(([dPost,lTime])=>{
console.log(dPost.title);
console.log(lTime);
}).catch(err=>console.log(err));
}
userActivity();
userDeleteActivity();