What I'm trying to do is make the empty array log the years-array in a for loop. The years are showing up perfectly fine, but I keep getting undefined
at the end of the console. Can someone please explain to me why this is happening?
P.S - Self-taught developer here so please bear with me, thank you!
var empty = [];
var years = [1996, 1997, 2001, 1975, 1943];
for(var empty = 0; empty <= years.length; empty++) {
console.log(years[empty]);
}
See Question&Answers more detail:os