<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Factorial using javascript</title>
</head>
<body>
<div class="container">
</div>
<script>
var num = prompt("Enter the number which do you want to factorial",1);
fact = [];
for (let index = 1; index <= num; index++) {
fact.push(index);
}
alert(`factorila of ${num} is ${fact.reduce(factorial)}`);
function factorial(total,number){
console.log(total, number)
return total * number;
}
</script>
</body>
</html>
Thanks you for commenting your questions. I will see question and respond you.