I'm writing a small script in JavaScript to output an array. I want to use the 'years' array, push the data into another array called new_array, and output it via console.log().
The only problem is, this is the output!
years = [1996, 1994, 1981, 1976];
new_array = [];
for(i = 0; i <= years.length; i++) {
popped_element = Object.values(years.pop([i]));
new_array.push(popped_element);
console.log(new_array)
}