JavaScript Program to find factorial of a number
In this program, You will learn how to find factorial of a number in JavaScript.
for (init; condition; increment/decrement) {
// statement
}
Example: How to find factorial of a number in JavaScript
let num = parseInt(prompt("Enter a number:"));
let f = 1;
for (i = 1; i <= num; i++) {
f = f * i
}
console.log("Factorial is:" + f)
Output:
Enter a number:> 5
Factorial is:120