# JS FUNCTIONS AND MORE BASIC QUESTIONS

Am learning how to create webpages, i have gone through basic html n css, now am trying to make javascript work but theres alot am not understanding about the code, so i was just viewing fuctions in js and having trouble understanding this statement...

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

console.log(factorial(3))

### Discussion  Ignacio Martin Vazquez

Is a recursive function, it says
Function factorial recieves a number.
Then, if the number is less than 2, returns 1, else return the number plus the result of the same function, but passing the number -1. Si if You call factorial of 4, ir would compare if it's less than 2, as isnt, it would return the multiplication of 4 by the result of factorial of 3, then it would compare if 3 is less than 2, it is not so, se have the same thing, it's gonna wait the result of 3 by factorial of 2, 2 is not less than 2, so we get in the implicit end of the recursive call, 2 * factorial of 1 , here, 1 is less than 2, so ir returns 1, and all the return begins to work. If You need more explination search for recursive functions  