Morning guys,
I’ve just finished the Factorialize a Number bonfire, and I was hoping to clarify one of the test requirements. To pass, you need to make sure factorialize(0) returns 1, but I’m having trouble understanding why that is.
Since factoring is 1 * 2 * 3… up until n, shouldn’t this make factoring 0 return 0?
Here’s how I got past the test, but I’m not confident I completed the task with a solid understanding:
function factorialize(num) {
//var to be updated in loop.
var updateVal = num;
for (var i = 1; i != num; i++) {
updateVal *= i;
}
num = updateVal;
//checking if num was zero
if (num === 0) {
return 1;
} else {
return num;
}
}