What do you mean shorthand notation in the function?

I have a function factorial
function factorial(n) {
 return (n < 2) ? 1 : factorial(n - 1) * n;
}


what do you mean this entry: factorial(n - 1)? As it is differently written?

Thanks to all, understood)
April 19th 20 at 12:49
2 answers
April 19th 20 at 12:51
Solution
This recursion under certain conditions.
How to write it differently? - Misty_Bernhard83 commented on April 19th 20 at 12:54
@Misty_Bernhard83, why? - erich16 commented on April 19th 20 at 12:57
@erich16to understand how it works - Misty_Bernhard83 commented on April 19th 20 at 13:00
@Misty_Bernhard83to understand how this works, we must first understand what is the factorial, as it is in mathematics. - erich16 commented on April 19th 20 at 13:03
April 19th 20 at 12:53
As already said, this is recursion, it is possible to write something like this.
function factorial(n) {
 let f = 1;

 for (var i = 2; i <= n; i++) {
 f *= i;
}

 return f;
}

Find more questions by tags JavaScript