Hi, so I was practising the 3 challenges for loops and arrays at the end of Javascript part I.

When I faced the factorial challenge, I did a search for a solution to calculate the factorial.

I’ve found a function expression that solves it, but I couldn’t figure out what exactly was going on.

The expression is:

const factorial = function fac(n) {return n < 2 ? 1 : n * fac(n - 1);

I understand that first it checks if the given argument is less than 2, so it would return 1, and if not it calculates the factorial.

I didn’t get the placeholder “fac(n)”, I know could be any other name like “factorial(x)”, but couldn’t understand how javascript is calculating the result exactly, can someone clarify?