Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                /**
Mir ist wichtig, dass nicht nur throw new Error() ausgeführt wird, wo ich eine Fehlermeldung sehe, sondern dass die Funktion auch Fehler zurückgibt und sehen kann für welchen Parameter es Probleme gibt und was das Problem ist, so dass ich in einem späteren Script entsprechend darauf reagieren kann.
*/

/** Object for parameter status */
let objParameters = {
  strName:{
    status:'',
    msg:''
  },
  intAge: {
    status:'',
    msg:''
  }
}

/** Call function to check parameters */
const objCheckedResult = check(1,'30');

/** Log the result object of checked parameters */
console.log('result: ', objCheckedResult);

/** Check parameters */ 
function check(strName,intAge){
  /** outer try/catch block */
  try {
    
    /** 1. inner try/catch block to check the 1st parameter: strName */
    try{
      if(typeof strName !== 'string') throw '1st parameter must be a string!';
    }
    catch(err){
      objParameters.strName.status = false;
      objParameters.strName.msg = err;
    }
    /** 2. inner try/catch block to check the 1st parameter: intAge */
    try{
      if(!Number.isInteger(intAge)) throw '2st parameter must be an integer!';
    }
    catch(err){
      objParameters.intAge.status = false;
      objParameters.intAge.msg = err;
    }        
   
   /** outer try block condition to check if there an error */
   if(Object.values(objParameters).includes(false)) throw objParameters;

  }
  /** outer catch block to throw a new error and stop the code */
  catch (err) {
    console.log('err: ', err);
    throw new Error(`Parameter problem...: ${err}`);
  }
  /** The function return the object for parameter status */
  finally {
    return objParameters;
  }
}

              
            
!
999px

Console