'FCC'에 해당되는 글 1건

:: Study Recursion Function

::: How replay function self

function sum(arr, n) {
  // Only change code below this line
  // :: When n is 0 or minus, Don't Sum anything.
  // ::: also When you last Index
  if(n <= 0) {
    return 0;
  } else {
    // :: Remember first value and Call <Next : self(n - 1)>
    return arr[n - 1] + sum(arr, n - 1);
  }
  // Only change code above this line
}
블로그 이미지

RIsN

,