Tell us what’s happening:
On the first iteration of the code below, does “i” index as it’s declared value of “0” or does it index as “1” because of the increment? Is the value of “i” only incremented after the first iteration is executed? For example: on the first round is it “product *= arr[0]” or “product *= arr[1]”
Your code so far
function multiply(arr, n) {
var product = 1;
for (var i = 0; i < n; i++) {
product *= arr[i];
}
return product;
}
function sum(arr, n) {
// Only change code below this line
// Only change code above this line
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36
.
Challenge: Replace Loops using Recursion
Link to the challenge: