In this task: "However, notice that multiply(arr, n) == multiply(arr, n - 1) * arr[n - 1] "
multiply(arr, n) == multiply(arr, n - 1) * arr[n - 1]
It seems like not correct.
Or not?
In this task: "However, notice that multiply(arr, n) == multiply(arr, n - 1) * arr[n - 1] "
multiply(arr, n) == multiply(arr, n - 1) * arr[n - 1]
It seems like not correct.
Or not?
Not quite. The description is accurate. You are forgetting about zero based indexing.
Check out this example:
let myArr = [2, 7, 8, 12];
let n = myArr.length;
console.log(myArr[n - 1]); // Should say 12
console.log(myArr[n]); // Will cause an error
n in function call refers to array length and n in arr[n - 1] refers to array index which is … (read above
) 