Factorial function in JavaScript

factorial = function(data) {
var result = 1;
for(var i = 0; i < data; i++){ result += result * i; } return result; }; console.log(factorial(6)); // -> 720;

Add your comment