JavaScript - Adding TWO Numbers
let num_1 = parseFloat(prompt("Enter the 1st number:"));
let num_2 = parseFloat(prompt("Enter the 2nd number:"));
let sum_1 = num_1 + num_2;
alert("The sum of two numbers is : " + sum_1);
Explanation
User Input:
User input is received by the prompt() function, which uses parseFloat() to turn it into a number.
Addition:
The two values are added using the + operator, and the outcome is stored in the sum variable.
Display Result:
The total is displayed in a popup message via the alert() function.