Answer the question
In order to leave comments, you need to log in
What does the abbreviation in function mean?
I have a factorial function
function factorial(n) {
return (n < 2) ? 1 : factorial(n - 1) * n;
}
Answer the question
In order to leave comments, you need to log in
As already said, this is recursion, this factorial code can be rewritten somehow like this.
function factorial(n) {
let f = 1;
for (let i = 2; i <= n; i++) {
f *= i;
}
return f;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question