Jquery clone() of an array seems to be cloning twice
<p>I am trying to auto populate a date range of visible elements.   The code I have works fine as long as there is only one empty end date that is filled, but I am having difficulty understanding why the clone() method is running twice.</p>

<p>Fiddle is <a href="http://jsfiddle.net/chrisfrisina/jYnZy/" rel="nofollow">here</a>.</p>

<p>Basically they are jobs, and roles.   A job can have many roles, and I guess roles within a parent job could have overlapping start and end times, but is not necessary for this aspect.   The Jobs can, and do, overlap start and end times.   The code works by looking for the start and end times described within the HTML of the ROLES, and if there is no end time designated, then to populate the roles end time as "CURRENT".   Then, to populate the JOB times, it gathers all of the start times in the array <code>start</code> (var start = []) and all the end times in the array <code>end</code> (var end = []).   It then sorts <code>start</code> and <code>end</code>, and takes the first <code>start</code> index(date) for the beginning of the JOB, and the last index(date) of <code>end</code> for the JOB's end date.    Somehow the issue is in the line <code>$(this).find('&gt;h1').after($('.workexperience time.end[datetime=' + end[end.length-1] + ']').clone());
</code>, as the arrays seem to be correct.    </p>

<p>Can you help point me in the right direction of the error in my code?</p>

<p>per nnnnnn:
the query <code>$('.workexperience time.end[datetime=' + end[end.length-1] + ']')</code> PRIOR TO THE CLONE is:</p>

<p>[
​Current ​​
, 
​Current ​​
]</p>

<p>[
​Sep 2012​​
]</p>

<p>[
​Current ​​
, 
​Current ​​
, 
​Current ​​
, 
​Current ​​
]</p>

<p>[
​Mar 2006​​
]</p>

<p>[
​Jun 2002​​
]</p>

<p>The query <code>end[end.length-1]</code> of the variable end results in :</p>

<p>2012-11</p>

<p>2012-09</p>

<p>2012-11</p>

<p>2006-03</p>

<p>2002-06 </p>
