Recursion in array

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

function sum(arr, n) {
// Only change code below this line
if (n===1){
return arr[0];
}
else if (n<=0){
return 0;
}
else{
return arr[n-1]+arr[arr[n-1]-1]
}

// 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/99.0.4844.51 Safari/537.36

Challenge: Replace Loops using Recursion

Link to the challenge:

What exactly are you asking? Your code is confusing, so I don’t exactly understand what you are trying to get each line to do.

Its regarding recursion in array problem.
Actually my this code also solving the problem, I want ask whether this code is recursion or not.

That code shouldn’t be able to pass the tests.

Why, I have tested in vs code it gives all results correctly.

This is not recursion and doesn’t actually accomplish the task, so any tests passing are a fluke.

Nowhere in the function do you call itself, so it is not recursion.

This is not a valid formula for computing the sum of an array.

Thank you, concept of recursion got cleared.