Problem 24. Use reduce to calculate factorial of a given number from an array of first n natural numbers (n being the number whose factorial needs to be calculated).

let arr = [1, 2, 3, 4, 5, 6, 7, 8];
let val = arr.reduce((val1, val2)=>{
    return val1*val2;
});

console.log(val);   // 40320