Factorialize a number


Problem Description
You are given the number n as an argument. You have to implement the function findFactorial which will return the factorial of the given number n.

A factorial is the product of all positive integers less than or equal to n. Factorials are often represented with the shorthand notation n!

For example: 5! = 1 * 2 * 3 * 4 * 5 = 120

Please note: Only numbers greater than or equal to zero will be supplied to the function.

Hint 1: We can use loops to solve this problem.

Hint 2: 0! is equal to 1.

Sample Input 1
5

Sample Output 1
120

Explanation
5 factorial is 1 * 2 * 3 * 4 * 5 i.e 120.

Sample Input 2
6

Sample Output 2
720

Explanation
6 factorial is 1 * 2 * 3 * 4 * 5 * 6 i.e 720.

6 Step Strategy to solve problems
Use the 6 step strategy to solve any problem

Understand the problem

Design test data/test cases (i.e. input and expected output)

Derive the solution (write pseudo code for the solution)

Test the solution (do a dry run of the pseudo code for the test data and confirm it works)

Write the program/code (using JavaScript here)

Test the code (debug any syntax errors and logical errors)

/**
 * @param {number} n
 * @return {number}
 */


function findFactorial(n) {
  
  // You only need to implement this function.
}

if (findFactorial(4) !== 24)
  console.log("Test fails: Expected 24 for input n = 4");
else
  console.log("Sample test case for input n = 4 passed!");

module.exports = findFactorial