I am trying to loop over an HTMLCollection but it appears as though the break-condition is met before the loop is entered. Furthermore, when I print the HTMLCollection to console, it returns the HTMLCollection and I can see that there are elements in it, however, when I try to print any of its indices, it returns undefined
Here is the code:
var applicant_elements = document.getElementsByClassName('applicant');
console.log(applicant_elements); // returns the HTMLCollection
// with length of 8
// and valid elements
console.log(applicant_elements[0]); // returns undefined
for (var i = 0; i < applicant_elements.length; i++) {
console.log('hello'); // this is never logged
}
Here is what is logged from the above code:
I should also state that I am running the following code within an angularJS controller. Not sure if that changes anything, but I feel like it shouldn't