thank you for your time.
I studied the Fibonacci function, and one of the answers below:
function fibonacci(n) { return (function(a, b, i) { return (i < n) ? arguments.callee(b, a + b, i + 1) : a; })(1, 1, 1); } console.log(fibonacci(51))
Since .callee arguments are forbidden in strict mode after ES5, I replace it with a function name. After that, I saw part i + 1, and I replaced it with i ++, which turned out to be too much recursion.
function x(n){ return (function y(a, b, i){ return (i < n) ? y(b, a + b, i++) : a; })(1,1,1) } console.log(x(51))
After several debugs, I found out that I + 1 works fine, while I ++ do not.
So, did I use ++ the wrong place, or didnβt I understand ++ at all?
Thnx again.
source share