+ 1
What is the output of this code?
function a(x){ if(x > 0){ console.log(x * a(x - 1)); }else{ return 1; } } a(3);
5 Answers
+ 4
Kelechi Ikpo Oh haha :)) Too clever you are, xD!
+ 4
Kelechi Ikpo
Did you ask that question to test out knowledge?
Well wrong place, ask such "test" questions on feed post. Self Answering is considered as offense. I would suggest you to remove the thread from here.
+ 1
Output :
1
NaN
NaN
Because you are using console.log inside the function and the function itself is a recursive function :))
I think you supposed to write this :
function a(x){
if(x > 0){
return x * a(x - 1);
}else{
return 1;
}
}
console.log(a(3)); // 6
0
Thank you Are Rahim Badsa
0
Rick Grimes Thank you. I never knew that such is offensive. It actually came out in the path of self discovery that I often fail not because I don't know but as a result of not being careful to read through questions.
Thank you for the guidance.



