javascript code to add two numbers code example
Example 1: how to add two numbers in javascript
let a = 4;
let b = 5;
document.write(a + b);
Example 2: add two numbers javascript
var x = 2 + 3;
//x = 5
Example 3: 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);