Tell us what’s happening:
Hi, my function returns 0 and I am not quite sure why. Can someone help me understand what I am doing wrong?
Your code so far
function factorialize(num) {
if (num===0) {
return 1;
}
var numbers = [];
var factorial = 0;
for (i=num; i>0; i--) {
numbers.push(num);
num--;
}
for (i=0; i<numbers.length-1; i++) {
factorial *= (numbers[i] * numbers[i+1]);
}
return factorial;
}
factorialize(5);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/factorialize-a-number