+ 6
Can you help me explain how this code works in JavaScript?
function fib(num){ if (num<=2) return 1; return fib(num-1)+fib(num-2); } alert(fib(6)); /* This code output 8. I'm learning programming by myself about 1 month. I try so hard to understand how it work but I can't. If it too long to write somethings easy to explain it so please tell me what I have to learn to understand that code. Thank you so much. */
2 Answers
+ 7
That is a challenge question in JS course, I'm not create that code so I didn't figure out even .. You know, but I think I need to learn more about something related to "self-invoking" of function. Thank for your help, I can see you are a enthusiastic person. Best luck to you:)
+ 2
here is your question ššbut it outputs undefined
https://code.sololearn.com/W1LNSuyz4A0k/?ref=app
i dont know if you framed the question well but i tried my best to answer.....even though am not quite good in this stuff