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/118.0.5993.2470 YaBrowser/23.11.0.2470 Yowser/2.5 Safari/537.36
Challenge Information:
Basic JavaScript - Replace Loops using Recursion
Who understands what is needed and how to do this in this task? Why is recursion needed? I don’t understand anything from the instructions, what it returns and how, then they say 1 then 0, it’s not possible to understand
function multiply(arr, n) {
let product = 1;
for (let i = 0; i < n; i++) {
product *= arr[i];
console.log(product)
}
return product;
}
multiply(8,9)
I also don’t understand how this code works, in a loop we go through n from 9 to 1 in the range of values 8, it turns out that the result is 8[1,2,3,4,5,6,7,8,9] and how What is multiplied by product?
On this site it is impossible to understand the examples and instructions, if I give examples and they can’t explain it to me, then it’s not the student’s fault, but here they can’t explain it so that the student understands the code,
With pleasure, but there I went through the examples, and here I now understand why there are answers, because the student will never understand your instructions.
Plenty of people do understand the instructions. I suspect that whatever translation tool you have between Russian and English isn’t very good for this sort of translation.