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

JavaScript

Display a “page”. any hints, suggestions and comments are very much appreciated thank you in advance for your help

Question:

function showPage(list, page) { // create two variables which will represent the index for the first and last student on the page

// select the element with a class of student-list and assign it to a variable

// set the innerHTML property of the variable you just created to an empty string

// loop over the length of the list parameter // inside the loop create a conditional to display the proper students // inside the conditional: // create the elements needed to display the student information // insert the above elements }

My answer:

function showPage(list, page) { let last = page * 10; let first = last - 10;

for (var i = 0; i < student.length; i++) { if (i >= last || i < first) { student[i].style.display = "none"; } else { student[i].style.display = "";
} }