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//use parseFloat(x); to change string to number
2a=10;
3b=20;
4console.log(parseFloat(a)+parseFloat(b));//this will give a+b=30
5//while
6consle.log(a+b); //will give a+b=1020 [as String]
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