Script with Errors Example

This is identical to the previous example, except the script has two errors. One is fatal, which causes the script to not execute. Once you fix that, the script will execute, but the formula for computing the area is not accurate. The formula error is a non-fatal error made by the programmer that simply results in an incorrect calculation.

Types of Errors: Fortunately, browsers have a built in JavaScript Console that will help you detect fatal errors. This example shows the Chrome browser's JavaScript Console, but all modern browsers have a similar utility.

If you don't use a JavaScript Console for the remainder of the JavaScript assignments, you are making a huge mistake.
  
    Chrome Browser:
    View → Developer → JavaScript Console
    
There are shortcut keys to make it easier to open the console.
  
    Mac:      Cmd + Option + J
    Windows:  Ctrl + Shift + J
    
When sitting down to work with JavaScript, popping the console should become a reflex action. It can save you lots of time since syntax errors can be hard for the human eye to detect.

Some screen shots are included below to show how the console shows the fatal error when this script loads.

JavaScript Console Screen Shot



JavaScript Console Screen Shot