# Nesting For Loops: Why do you have to check the [i] length?

I have a question about the Inner Loops lesson:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/nesting-for-loops

For the inner For Loop, I used

``````for (var j = 0; j < arr.length; j++)
``````

In theory, shouldn’t this also work, since arr.length is 3? The solution tells me I need to use `arr[i].length`

The solution they gave was:

``````function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i=0; i < arr.length; i++){
for (var j=0; j < arr[i].length; j++){
product = product * arr[i][j];
}
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
``````

But `arr` is `[1,2]` - so you need to iterate over only two numbers, and `arr.length` is 2

`arr`is `undefined`, I think the multiplication with this would result in `NaN` (Not a Number), so you would not get the result you want

Oh that makes sense. I thought it would only multiply however long the array is. Thank you!!