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

querySelector method .hints, suggestions and comments are very much appreciated thank you in advance for your help

Question:

Next use the querySelector method to select the UL element with a class of student-list and assign it to a new variable named studentList. This is the element we will be adding our student data to.

Now set the innerHTML property of the studentList variable to an empty string. This will remove any existing students that might have been displayed previously.

Next we will create a for loop that will run once for each object in the list parameter. We can do this by using the length property of list.

Inside the loop, create a conditional statement that checks if i is greater than or equal to the startIndex variable and less than the endIndex variable. The student at these indexes are the ones we want to display on the page.

If that condition is met, we will create the DOM elements needed to display the student at that index, which we will assign to a variable named studentItem. We will create these elements using a template literal. Use bracket notation to access the student object at that index and dot notation to access the specific properties of that student object. The end result should be elements that look like this:

My answer:

let StudentListItem = document.getElementsByTagName('li'); console.log(StudentListItem.length); const pageLink = document.createElement('a'); pageLink.className = 'active'; pageLink.href = '#'; pageLink.textContent = i + 1; pageli.appendChild(pageLink); buttonUl.appendChild(pageli);

<li class="student-item cf"> <div class="student-details"> <img class="avatar" src="https://randomuser.me/api/portraits/thumb/women/16.jpg"> <h3>Miss Natalie Arnold</h3> <span class="email">natalie.arnold@example.com</span> </div> <div class="joined-details"> <span class="date">Joined 06-25-2019</span> <span class="age">1</span> </div> </li> <li class="student-item cf"> <div class="student-details"> <img class="avatar" src="https://randomuser.me/api/portraits/thumb/men/48.jpg"> <h3>Mr Allen Thompson</h3> <span class="email">allen.thompson@example.com</span> </div> <div class="joined-details"> <span class="date">Joined 08-14-2010</span> <span class="age">10</span> </div> </li> </ul>