Q:

How to make a function that returns the factorial of each integer in an array

This question has been deleted

A:

First off, make a recursive function that calculates the factorial of a single number:
function factorial(num) {
    if (num == 0 || num == 1) {
        return 1;
    }
    return num * factorial(num - 1);
}

Then to do it for an array, just use Array.prototype.map() like so:
function getFactorials(arr) {
    var result = arr.map(x => factorial(x));
    return result;
}

Here's a demonstration:

 

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

function getFactorials(arr) {
    var result = arr.map(x => factorial(x));
    return result;
}

console.log(getFactorials([4, 8, 10])); 
console.log(getFactorials([]));
console.log(getFactorials([1, 2, 3, 4, 5]));

Hopefully this helps!

A:

You need to separate function into two functions, one for iterating the array and collecting the calculated values and the other to get the facorial of a number.

function getFactorials(nums) {
    var result = [],
        i;
        
    for (i = 0; i < nums.length; i++) {
        result.push(getFactorial(nums[i]));
    }
    return result;
} 

function getFactorial(n) {
   if (n === 0 || n === 1) return 1;
   return n * getFactorial(n - 1);
}

console.log(getFactorials([]));
console.log(getFactorials([3]));
console.log(getFactorials([3, 4, 5]));
console.log(getFactorials([3, 8, 9, 10]));

