JavaScript Program to Create a JavaScript Function to Add Two Numbers

Write a JavaScript program to create a function called sum() to add two numbers.



Source Code
<html>
<head>
    <title>Function to calculate sum of two numbers</title>
    <script>
    function sum(val1, val2) 
    {
        var result = val1 + val2;
        document.write(result + "<br/>");
    }
    </script>
</head>
<body>
<script>
    sum(23, 19);
    sum(32, 56);
    sum(12, 52);
</script>
</body>
</html>
Output