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