This is shortcut method: Using reduce method let n=[1,2,3,4,5]; let fact=(a , b)=>{ return a*b; } console.log("Factorial are", n. reduce(fact));