JSFiddle - React, Tailwind, and code Playground
by jfriend00
JavaScript
function fnDrawPrism(length, width, height){
//If any of these parameters are undefined, throw an error that lists the missing parameters.
var argNames = ["length", "width", "height"];
if (arguments.length < argNames.length) {
throw new Error(argNames[arguments.length] + " is undefined");
}
for (var i = 0; i < arguments.length; i++) {
if (arguments[i] === undefined) {
throw new Error(argNames[i] + " is undefined");
}
}
// now that all args are defined do the business of the function
return length*width*height;
}
console.log("A");
fnDrawPrism(1,2,3);
console.log("B");
fnDrawPrism(1,2);
console.log("C");