10
I am learning Javascript and I am breaking my head with this code that I created. Why is my function concatenating instead of summing the numbers I store in the variables?
<!DOCTYPE html>
<html>
<head>
<title>Aula 05 Java Script</title>
<meta charset="utf-8">
<script type="text/javascript">
var num1,num2;
num1 = prompt("Digite um número ","");
num2 = prompt("Digite outro número para somar ","");
function soma(){
var res;
res=num1+num2;
alert("Reultado da Operação "+ res);
}
soma();
</script>
</head>
<body>
</body>
</html>
We responded in the same minute :)
+1
– Sergio
Thank you so much! Now besides solving I understand the reason! .
– Kleber Stumpf