1const num1 = 5;
2const num2 = 3;
3
4// add two numbers
5const sum = num1 + num2;
6
7// display the sum
8console.log('The sum of ' + num1 + ' and ' + num2 + ' is: ' + sum);
1<!--Add two integer numbers using JavaScript.-->
2<html>
3 <head>
4 <title>Add two integer numbers using JavaScript.</title>
5 <script type="text/javascript">
6 function addTwoNumbers(textBox1, textBox2){
7 var x=document.getElementById(textBox1).value;
8 var y=document.getElementById(textBox2).value;
9 var sum=0;
10 sum=Number(x)+Number(y);
11 alert("SUM is: " + sum);
12 }
13 </script>
14 </head>
15<body>
16 <h1>Add two integer numbers using JavaScript.</h1>
17 <b>Enter first Number: </b><br>
18 <input type="text" id="textIn1"/><br>
19 <b>Enter second Number: </b><br>
20 <input type="text" id="textIn2"/><br><br>
21 <input type="button" id="btnSum" value="Calculate SUM" onClick="addTwoNumbers('textIn1','textIn2')"/>
22</body>
23
24</html>
25
1// Prints the sum of 2 float numbers
2function addition(number_1, number_2)
3{
4 int sum = number_1 + number_2
5document.write(sum)
6}
7
8var number_1 = parseFloat(prompt("First Number"));
9var number_2 = parseFloat(prompt("Second Number"));
10addition(number_1, number_2);