in this code snippet i want to sum 2 value that is inserted into prpmpts(values that are numbers other wise alert wrong input). but my problem is when i even insert numbers it alert wrong input and not sum values
function sumation(a,b){
if (typeof a == "number" && typeof b == "number")
return (a + b);
else
alert("wrong input")
}
window.onload = function(){
var val1 = prompt("insert first number","");
var val2 = prompt("insert second number","");
var result = sumation(val1,val2);
alert(result);
};
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<script src="newjavascript.js"></script>
</body>
</html>