Trying to do the factorial recursively in Javascript, I get 2 different errors, why does this happen? and how should it be done? ( According to my code )
/* 1ra forma */
function f1(n){ // Maximum call stack size exceeded
if(n < 1) return n;
else return f1(n * (n-1));
}
/* 2da forma */
function f2(n,neutro=1){ // Devuelve 1
if(isNaN(n)) n = parseInt(n,10);
if(n < 1) {return neutro;}
else {
neutro *= n;
return f2(n-1)
}
}