I attempted to create a function that accepts a parameter and populates an array with numbers less than the parameter down to zero in descending order. I then used a for loop to multiply each element in the array by the next element, but unfortunately, my return value is coming back as null. Can someone please assist me with this issue?
function factorialize(num) {
var arrayOfFactorial = [];
var factorial = 1;
for (var i = num; i > 0; i--) {
arrayOfFactorial.push(i);
factorial = factorial * arrayOfFactorial[i];
}
return factorial;
}
factorialize(10);