function myFactorial(number) { var fact = 1; var i = number; while (i >= 1) { fact = fact * i; i--; } return fact; } console.log(myFactorial(6)); //Output: 720;