Untitled
unknown
javascript
9 months ago
782 B
14
Indexable
const postlar = [
{ sayi: 1, başlık: "6. Bölge" },
{ sayi: 2, başlık: "5. Bölge" },
{ sayi: 3, başlık: "3. Bölge" },
{ sayi: 4, başlık: "2. Bölge" },
{ sayi: 5, başlık: "4.Bölge" },
{ sayi: 6, başlık: "1.Bölge" }
];
function fetchPosts() {
return new Promise((resolve) => {
setTimeout(() => {
resolve(postlar);
}, 9999);
});
}
async function ilkbeşpostugöster() {
try {
const data = await fetchPosts();
const firstFive = data.slice(0, 5);
console.log("İlk 5 Bölge Başlığı:");
firstFive.forEach(post => console.log(post.başlık));
} catch (hata) {
console.error("Bir hata oluştu:", hata);
}
}
ilkbeşpostugöster();Editor is loading...
Leave a Comment