The blog provides the step by step solution to write the JavaScript program to add two numbers and display their sum.
To understand the below given program , user should have knowledge on below given topics
Steps for Adding two Numbers in JavaScript
- Input user to enter the first number and store the value into variable
- Input user to enter the second number and store the value into variable
- Create another variable to store the sum of first number and second number
- Use the Operator + to sum the values
- Display the total sum
<html> <head> </head> <body> <script> const firstNumber = parseInt(prompt('Input first number ')); const secondNumber = parseInt(prompt('Input second number ')); const sum = firstNumber + secondNumber; document.writeln(`The sum of ${firstNumber} and ${secondNumber} is ${sum}`); </script> </body> </html>