Q:

Javascript Factorialize returns incorrect result

Just wondering if anyone can tell me why this returns 100 and not 120? It should calculate the total number of the factor.
function factorialize(num) {

  for(var i = 1; i <= num; i++ ) {
    var fact = i+i;    
    total = fact * fact;
  }
  return total;
}

factorialize(5);

A:

If you are trying to calculate the factorial, use this code:
function factorialize(num) {
  var total = 1; // Initialize the total. 0! = 1.
  for(var i = 1; i <= num; i++ ) {

    total = total * i; // Add the current index to the factors by multiplying it by the current total.
  }
  return total;
}

