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.



I'm confused by a piece of this code http://imgur.com/CFi4aAh

1 Answer

Jesus Mendoza
Jesus Mendoza
23,274 Points

Hey Rostyk,

var employees = JSON.parse(xhr.responseText); /* responseText is the text that came in the ajax call. You are just parsing that content into an object. */
var statusHTML = '<ul class="bulleted">'; // This is the element created to contain the list of employees names.

// Loop trought all the employees stored in the employees variable.

/* If the employee is at the office then concatenate this string to the statusHTML variable. (It will create a list element with the class 'in' the office. */
statusHTML += '<li class="in">';
/* If the employe is not at the office then concatenate this string to the statusHTML variable.
statusHTML += '<li class="out">';

/* Now the statusHTML variable should look something like this
<ul class="bulleted">
<li class="in"> or <li class="out">

// Add the employee name to the statusHTML string
statusHTML += employee[i].name;
statusHTML += '</li>';

statusHTML += '</ul>';

/* If you have 3 employees the result HTML should look something like this
<ul class="bullted">
<li class="in"> or <li class="out">
<li class="in"> or <li class="out">
<li class="in"> or <li class="out">