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 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) {
condition
      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 =
    statusHTML;
  }
};

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

1 Answer

Steven Parker
Steven Parker
229,744 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