Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Jan Xavier Virgen](https://uploads.teamtreehouse.com/production/profile-photos/11563342/micro_Photo_of_me_2.jpg)
Jan Xavier Virgen
Full Stack JavaScript Techdegree Graduate 19,751 PointsProject 2 - Pagination. First Item shows undefined.
Hi everyone,
I've been stuck with pagination but slowly making some progress. it's almost the result that I want my showPage() function to display but the first item shows undefined.
Can you please help me out?
const perPage = 10;
let studentList = document.querySelector(".student-list");
let html;
let showPage = (arrayObjects, page) => {
let startIndex = (page * perPage) - perPage;
let endIndex = (page * perPage);
for (let i = 0; i < arrayObjects.length; i++){
if(i >= startIndex && i < endIndex){
let items = arrayObjects[i]
html += `
<li class="student-item cf">
<div class="student-details">
<img class="avatar" src="${items.picture.thumbnail}" alt="Profile Picture">
<h3>${items.name.first} ${items.name.last}</h3>
<span class="email">${items.email}</span>
</div>
<div class="joined-details">
<span class="date">Joined ${items.registered.date}</span>
</div>
</li>`
}
studentList.innerHTML = html;
console.log(html)
}
}
showPage(data,1);