re: Factorial Algorithm: ES5 & ES6 JavaScript Solutions VIEW POST

VIEW FULL DISCUSSION
 

How is it different from following?

function factorial(integer) {
   return integer ? (integer * factorial(integer - 1)) : 1 
}
 

Hi Akash,
as I mentioned in the post, there are many solutions to the Factorial Algorithm.

I chose those two because I like how self-explanatory is the code in the solution with while method and I like the second one because it's a nice short one-liner.

The one you are mentioning is the same as the second one in the post. The difference is that you are using function declaration/expression instead of an arrow function. With the ES6 arrow function, it's just shorter and a one-liner.

code of conduct - report abuse