Compute factorial of 5 using a loop and print the result (120).
Ready — edit the code above and click Run.
// See explanation
console.log("done");
Try solving on your own first, then reveal the official answer.
Iterative factorial avoids stack overflow for larger n. Use long for bigger values.