The pop() method using a for loop
<p>Can someone please tell me why the length of <code>secondArray</code>is 5 instead of 10? </p>

<p>The result I am looking for is for all elements to be popped off so the secondArray has an empty. However, it seems that only half of them are being popped off, even though I have set the (condition) of the for loop to go through the entire array. Can someone point out why this is?</p>

<p>Please Note: I understand this is not the only/or ideal way to remove elements from an array. This is simply some practice I am doing with for loops and Array methods.</p>

<p>my result looks like this after executing the code: </p>

<blockquote>
  <p>secondArray = 1,2,3,4,5,6,7,8,9,10</p>
  
  <p>secondArray = 1,2,3,4,5</p>
</blockquote>

<pre><code>var secondArray = [1,2,3,4,5,6,7,8,9,10];

document.write("secondArray = " + secondArray)

for(i = 0; i &lt; secondArray.length;  i++){
    secondArray.pop(); 
}

document.write("&lt;br/&gt;"+ "secondArray = " + secondArray)
</code></pre>