Javascript parseInt()

The parseInt() function parses string and returns an integar as a result.

Code Structure
var num1 = prompt("Enter the first number.");
num1 = parseInt(num1);
var num2 = prompt("Enter the second number.");
num2 = parseInt(num2);

var total = num1 + num2;
alert(total);

Share this

Related Posts