i have created a simple program in which it needs to add 1 and 3 and show 4 but it shows me 13 here is my program:
<html>
<head>
<style>
</style>
<script type="text/javascript">
function calculate(){
a = document.getElementById('num1').value;
b = document.getElementById('num2').value;
document.getElementById('result').innerHTML = a + b;
}
</script>
</head>
<body>
<input id='num1' value="1"/>
<input id='num2' value='3'/>
<p id='result'></p>
<button onclick="calculate()">Calculate</button>
</body>
</html>
What do i do now?
stringobjects, whereas addition is an operation performed on numeric objects. What do you think needs to happen for bothstringvariables to treat them as numeric?