title: Looping over an array, and pushing data to another array
body: <p>I'm writing a small script in JavaScript to output an array.
  <strong>I want to use the 'years' array, push the data into another array called new_array, and output it via console.log()</strong>. </p>
  
  <p>The only problem is, this is the output!
  <a href="https://i.stack.imgur.com/hj4Nb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hj4Nb.png" alt="enter image description here"></a></p>
  
  <pre><code>years = [1996, 1994, 1981, 1976];
  new_array = [];
  
  
  for(i = 0; i &lt;= years.length; i++) {
      popped_element = Object.values(years.pop([i]));
      new_array.push(popped_element);
      console.log(new_array)
  
  }
  </code></pre>