I understand that \"a\" solution is:
function Factorial(number)
{
if(number == 0 || number == 1){
return 1
It is called recursion.
This function is called like this
var result = Factorial(3); in Factorial function
First time return 3*Factorial(2);
Now here return statement doesnt get executed insted Factorial is called again.. so second time return 2*Factorial(1);
again in Factorial(1) Third time return 1;
So go to second return 2*1;
Next to first return 3*(2*1);
Finally var result = 3*2*1 = 6.