26 Create JavaScript. Program for creating overloaded method called 'Add ' to calculate the sum of two integers, two float numbers, one integer and one float.

Program:

<html>
    <script>

        function add(a , b )
        {
            var sum = a+b;
            alert("Addition:  "+sum);
        }
       
    </script>
    <body>
        <input type="button" id="b1" value="Add 2 Interger" onclick="add(10,20)"><br><br>
        <input type="button" id="b2" value="Add 2 Float" onclick="add(10.04,20.15)"><br><br>
        <input type="button" id="b3" value="Add 1 Interger and 1 Float" onclick="add(10,20.48)"><br><br>
       
    </body>
</html>


Output:

Overloaded add method



Previous
Next Post »