title: Looping through a List of objects in JavaScript
body: <p>I want to loop through the student list which I received from a REST service located on a server. this list contains objects for students enrolled in a section. Each object has firstName, lastName, student ID and many other attributes, specifically an attribute called <code>isAbsent</code>. Its a Boolean value where it has true if the student is absent and false if the student is present in not absent. I want to store the students IDs who are absent (have <code>isAbsent=true</code>) in another String Array. </p>
  
  <p>I tried this :</p>
  
  <pre><code>{ 
      //this array will store the IDs of students who are absent.
      $scope.selection = [];
      //$scope.studentList is the list of students for CRN=X and Date=Y
      for (id in $scope.studentList) {
          if ($scope.studentList.isAbsent === true) {
              $scope.selection.push($scope.studentList.id);
              console.log($scope.selection);
          }
      }
  }
  </code></pre>
  
  <p>This code doesn't execute. I have no clue why, I guess the problem in the loop structure. Any help?</p>