Skip to content

Commit 33b262e

Browse files
committed
hw2
1 parent 1bd7dab commit 33b262e

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

hw2.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const posts = [
2+
{ postName: 'Post1 ', author: 'yazar 1' },
3+
{ postName: 'post 2 ', author: 'yazar 2' },
4+
{ postName: 'post 3 ', author: 'yazar 3' },
5+
6+
]
7+
8+
const listPosts = () => {
9+
posts.map(post => {
10+
console.log(post.postName)
11+
})
12+
}
13+
14+
const addPosts = (newpost) => {
15+
const promise = new Promise((resolve, reject) => {
16+
posts.push(newpost);
17+
resolve(posts);
18+
reject('bir hata olustu');
19+
})
20+
return promise;
21+
}
22+
23+
async function showPosts (){
24+
try{
25+
await addPosts({ postName: 'Post 5 ', author: 'yazar 5' })
26+
listPosts();
27+
}
28+
catch(error){
29+
console.log(error);
30+
}
31+
}
32+
showPosts();

0 commit comments

Comments
 (0)