Problem with .each() function

Problem with .each() function

Hi all,
I have a problem with .each function.


I store strings in an array called " $list2" using .each function on an array(" allElems"). 
The problem is when I read $list2 I see that the word " undefined" is concatenated to one of the strings in the array.
I debugged it and I see that the last index is not supposed to be added, but it does.
For example:
Let's say there are nine (9) items in the array(" allElems") .
The index range of that should be 0-8, right?
When looping through it with .each, for some reason it counts 10th index. I can't figure why.
The  " undefined" is then concatenated to one of the strings in  $list2...
How do I solve this?