Functions are one of the fundamental building blocks in JavaScript. A function is a JavaScript procedure—a set of statements that performs a task or calculates a value.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<script> function add(n1,n2) { var sum = parseInt(n1)+parseInt(n2); alert(sum); } </script> <input type="button" value="Claculate Sum" onclick="add(12,13)"> |