Factorial using javascript

technical talkiess
0

 <!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 numprompt("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>


Tags

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)