Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript AJAX Basics (retiring) Programming AJAX Processing JSON Data

looks like the li is only closed for the else clause

 if(xhr.readyState === 4) { 
convert string to js, store in var employees
    var employees = JSON.parse(xhr.responseText);
generate ul w/html, store in var statusHTML
    var statusHTML = "< ul class='bulleted' >";
for loop, employee list stored in employee
    for (var i=0; i < employees.length; i += 1) {
      if (employees[i].inoffice === true) {
generate in class in
        statusHTML += '< li class="in" >';
generate out class
      } else {
        statusHTML += '< li class="out" >';
        statusHTML += '< /li >';
    statusHTML += '' ; 
    document.getElementById('employeeList').innerHTML =

omg..it worked!!! I finally learned how to post code to the forum :D

1 Answer

Steven Parker
Steven Parker
216,017 Points

That's not how it's done in the video. The video shows the name and the closing tag being added AFTER the else block, so every employee will get both.

oh yea, ty