Code HELP! PLZZZ

function sum(arr, n) {
  // Only change code below this line

  if(n=0){ //HERE ! WHY [ if(n=0)] WON'T WORK ??
return arr[0];
  }else {
    return sum(arr,n-1)+arr[n];
  }

  // Only change code above this line
}

Above , at the 4rth line if i put [if(n=0)] instead of [if(n<=0)] won’t work. The value of n will never go below zero . Then why n=0 won’t work !! :thinking::thinking:

There is a difference between a = b , a == b, a === b.

1 Like