Factorialize a Number _Maximum call stack size exceeded

Factorialize a Number _Maximum call stack size exceeded
0

#1

Tell us what’s happening:

Need help bro:
Why the first function will result in “Maximum call stack size exceeded”

Your code so far





function factorialize(num) {
  if(num == 0){return 1;}
  return num*factorialize(num--);
}

function factorialize(num) {
  if (num === 0) { return 1; }
  return num * factorialize(num-1);
}


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/factorialize-a-number


#2

The location of the decrement operator matters. num-- does not return the same thing as --num

factorialize(5)
num is 5
return 5 * factorialize(5)
  num is 5
  return 5 * factorialize(5)
    num is 5
    return 5 * factorialize(5)
      and so on

#3

Thks Bro :joy::kissing_heart: