Question:

Write a recursive factorial function and then verify that the factorial of 4 equals 24.

Answer:

function factorial(n) {
  if (n == 0) { return  1; }
  return n * factorial(n - 1);
}
console.log(factorial(4));

Keywords:

© 2017 QuizBucket.org