Factorialize a Number - last condition?

Tell us what’s happening:

This code, as far as I can tell, factorializes any number given it, took a lot of re-reading and such. But proud of myself.
However the final challenge test is factorialize(0) returns 1, which my code doesn’t pass.
Why is that a condition? Is 0! actually 1 in math? I can’t figure out how to make that happen. Any help appreciated.

Your code so far

function factorialize(num) {

  var array = [];
  for (num; num >= 1; num--) {
  var product = array.reduce(function(previousVal, currentVal) {
   return previousVal * currentVal;});
  num = product;
  return num;


Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36.

Link to the challenge:

Yes! 0! equals 1. You can add a special case in your code to check if the input is 0.

1 Like

Right on. What a crazy thing for 0 to do!