In this HackerRank Day 1: Functions 10 days of javascript problem solution Implement a function named factorial that has one parameter: an integer, n. It must return the value of n! (i.e., n factorial).

HackerRank Day 1: Functions problem solution

Problem solution in JavaScript programming.


/*
 * Create the function factorial here
 */
function factorial(n) {
  
    var factor =1;
    for(var i=1; i<=n; i++)
        factor = factor * i;
        return factor;
    
}