Ensure Error
by ronnjoe
JavaScript
function ensure(value) {
//try {
console.log(typeof value);
if(typeof value == "undefined"){
throw "No ars";
}
return value;
//}
/* } catch(e){
console.log(e);
} */
}
//ensure();
var abc = ensure();
console.log(abc);
function getRectArea(width, height) {
if (isNaN(width) || isNaN(height)) {
throw "Parameter is not a number!";
}
}
getRectArea(3, 'A');
/* try {
getRectArea(3, 'A');
}
catch(e) {
console.log(e);
// expected output: "Parameter is not a number!"
} */