I'm trying to figure out why my code does not throw and display the error message (page is just blank) after I call it with the following statement:
document.write(add(10,wrong_input));
program.js
var add = function (a,b){
if(typeof a !== 'number' || typeof b !== 'number'){
throw{
name: 'TypeError',
message: 'add needs numbers'
} catch(e){
document.writeln(e.name + ': ' + e.message);
}
}
return a + b;
}
program.html
<html>
<body>
<pre><script src="program.js"></script></pre>
<div></div>
</body>
</html>