Check the function parameters
<head>
<title></title>
<script type = "text/javascript" >
function addNums(firstNum,secondNum) {
if ((isNaN(firstNum)) || (isNaN(secondNum))) {
alert("Arguments must be numbers.");
return;
}
else if (firstNum > secondNum) {
alert(firstNum + " is greater than " + secondNum);
}
else {
return firstNum + secondNum;
}
}
</script>
</head>
<body>
<script type = "text/javascript" >
document.write(addNums("aaa",3));
document.write("<BR>");
document.write(addNums(2,3));
</script>
</body>
Related examples in the same category