Follow Us

LightBlog

Breaking

Showing posts with label Jquery. Show all posts
Showing posts with label Jquery. Show all posts

Sunday, July 1, 2018

July 01, 2018

Return statement in javascript function



<!DOCTYPE html>
<html>
<head>
    <title>Return statement in javascript function </title>
<meta charset="utf-8" />
</head>
<body>
    <script>
        function addition(n1,n2)
        {
            var total = n1 + n2;
            return total;
        }
        var res = addition(6, 5);
        document.write("addtion of two number:" + res);
    </script>
</body>
</html>

Out put : addtion of two number:11

.............................................................................User insert a value ..................................

<!DOCTYPE html>
<html>
<head>
    <title>Return statement in javascript function </title>
<meta charset="utf-8" />
</head>
<body>
    <script>
        var a = parseInt(prompt("Enter first number"));
        var b = parseInt(prompt("Enter Second number"));
        function addition(n1,n2)
        {
            var total = n1 + n2;
            return total;
        }
        //var res = addition(6, 5);
        var res = addition(a, b);
        document.write("addtion of two number:" + res);
    </script>
</body>
</html>


Out put :


addtion of two number:7