DEV Community

SELVAKUMAR R
SELVAKUMAR R

Posted on

Function in Java Script

Function:

It is set of instruction to perform the task

function can be declared under the { }

Function Define in Java script:

function function name () {

} 
Enter fullscreen mode Exit fullscreen mode

() - this brackets are used to get the parameters from the user

Once we define the function we call at many time we want in the program running

Function calling in java script:

Function name ()

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        add(5,10);
        sub(10,5);
        multi(5,2);
        division(10,5);
        mod(10,5);
        function add(num1,num2){

            console.log("Addition of numbers",num1+num2);

        }

        function sub(num1,num2){
            console.log("Subtraction of numbers",num1-num2);
        }

        function multi(num1,num2){
            console.log("Multiplication of numbers",num1*num2);
        }

        function division(num1,num2){
            console.log("Division of numbers",num1/num2);
        }

        function mod(num1,num2){
            console.log("Modules of numbers",num1%num2);
        }


    </script>
</head>
<body>

</body>
</html>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)