Tell us what’s happening:
Ok so I actually got the correct answer using recursion, but I went back to look at the solution using a for loop and was totally thrown off. I don’t understand why the exit condition for the loop is “num >= 1”. Seems to me that the exit condition should be num <= 1, or num <= 0, since that is when we want the loop to stop, correct? When num counts down from 5 down to 1 and stops. That’s how my mind is thinking of it anyway, but that answer doesn’t work. Can someone please explain why so I can comprehend?
Thanks!
Nick
Your code so far
function factorialize(num) {
for (i = 1; num >= 1; num--) {
i = num * i;
}
return i;
}
factorialize(5);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36
.
Link to the challenge: