Answers for "javascript function add two numbers"

4

js difference between two numbers

var difference = function (a, b) { return Math.abs(a - b); }
Posted by: Guest on February-21-2020
3

add two numbers in javascript

const num1 = 5;
const num2 = 3;

// add two numbers
const sum = num1 + num2;

// display the sum
console.log('The sum of ' + num1 + ' and ' + num2 + ' is: ' + sum);
Posted by: Guest on February-26-2021
4

javascript function to add two numbers

<!--Add two integer numbers using JavaScript.-->
<html>
	<head>
		<title>Add two integer numbers using JavaScript.</title>
		<script type="text/javascript">
			function addTwoNumbers(textBox1, textBox2){
				var x=document.getElementById(textBox1).value;
				var y=document.getElementById(textBox2).value;
				var sum=0;
				sum=Number(x)+Number(y);
				alert("SUM is: " + sum);
			}
		</script>
	</head>
<body>
	<h1>Add two integer numbers using JavaScript.</h1>
	<b>Enter first Number: </b><br>
	<input type="text" id="textIn1"/><br>
	<b>Enter second Number: </b><br>
	<input type="text" id="textIn2"/><br><br>
	<input type="button" id="btnSum" value="Calculate SUM" onClick="addTwoNumbers('textIn1','textIn2')"/>
</body>

</html>
Posted by: Guest on April-11-2020
-2

to add 2 numbers using function in javascript

// Prints the sum of 2 float numbers 
function addition(number_1, number_2)
{
  int sum = number_1 + number_2
document.write(sum)
}

var number_1 = parseFloat(prompt("First Number"));
var number_2 = parseFloat(prompt("Second Number"));
addition(number_1, number_2);
Posted by: Guest on August-12-2020

Code answers related to "javascript function add two numbers"

Code answers related to "Javascript"

Browse Popular Code Answers by Language