Sorry if this is blindingly obvious, but I can’t quite see why this works the way it does. I don’t feel like it’s as obvious an outcome as I’d expect to see. I’d be grateful if for an explanation!

I have the below function (from the first recursion lesson in JS) which will loop through an array and return the product of the first **n** elements of the array.

I would have thought it would multiply each element, add them together, then return the sum of those elements. However, it multiplies each element together (so 1 * 2 * 3 *4…etc) and returns this as the product. Why is this?

```
function multiply(arr, n) {
var product = 1;
for (var i = 0; i < n; i++) {
product *= arr[i];
}
console.log(product);
}
multiply([1, 2, 3, 4, 5, 6], 3);
```

**Your browser information:**

User Agent is: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36`

.

**Challenge:** Replace Loops using Recursion

**Link to the challenge:**