When I run the below JavaScript code the first two lines of output are:
5
undefined
Why is the second output line undefined and not 5? Here is the code:
matrix = [
[2, 5, 7],
[4, 6, 1],
[7, 3, 9]
];
for (var i in matrix) {
for (var j in matrix[i]) {
console.log(matrix[0][0 + 1]);
console.log(matrix[i][j + 1]);
}
}