# Nesting For Loops - what if variable outside the function

Tell us what’s happening:
Hello,

Quick question on this exercice. I have found and understood the solution.
But I am wondering on another point.
What if the variable product is already existing outside the function.
I have tried to declare the variable product first. Then I have tried to call the function with this variable. Please see the code below.

This is wrong but I don’t know why.

var product = 1;
function multiplyAll(arr, product){
for (var i=0; i < arr.length; i++){
for (var j=0; j < arr[i].length; j++){
product = arr[i][j] * product;
}
}
return product;
}
multiplyAll([[1,2],[3,4],[5,6,7]], product);

}

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

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

``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0`.

The problem is you created a function named `multiplyAll` inside a function with the same name. I’m not sure why you did that, because creating a new function inside isn’t necessary. The reason it didn’t work was because the function inside never ran, you didn’t call it, so it would return `1` everytime. Basically, this is what it should look like:

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