I happened to review recursion again and noticed that some people write recursion with and if else statement. The if being the base case and the else having the recursive call. However, I have been only using an if for the base case with no else, and just the recursive call under it. See below.
//using else
if(n === 0) return 0;
else if(n === 1) return 1;
else return fib(n - 1) + fib(n - 2);
//versus no else
if(n === 0) return 0;
else if(n === 1) return 1;
return fib(n - 1) + fib(n - 2);
Logically they are equivalent because of the returns. There is no difference in the result. But is there any reason to do one over the other? I feel like sometimes I flop between them, but I default to not using the else.