Salve a tutti.
Cosa non va nel seguente codice? Dovrebbe restituire un messaggio che il primo argomento della funzione non è un numero, invece mi dice che "a is not defined":
codice:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ES 7-2</title>
<meta name="author" content="g.nardella1" />
<script type="text/javascript">
function addNums(firstNum,secondNum){
if ((isNaN(firstNum)) || (isNaN(secondNum))){
alert ("Sorry, both 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">
alert (addNums (a,2));
</script>
</body>