Next page | Contents page |

What if it doesn't work?

As mentioned in a side box on the previous page, the syntax of a programming language is strict. You must use the right letter cases and punctuation. The type of brackets matters: function parameters are in smooth brackets, or parentheses: () but function bodies are in curly braces: {}. In some fonts it can be hard to tell them apart but it does matter.

If you have checked all that, the next thing to do is to look for your browser's Error Console, which is likely to pop up as a separate window.

Once you have an error console, clear its contents (there will be a button). Then try to view the problem page again. The error console should then show any errors that occurred and probably give you the line number in the .js file at which the problem was detected. That does not mean that particular line is wrong but it usually gives a clue as to what is wrong.

Another thing you can do if your program is partially working is to insert an extra line to pop a message window up, so you can tell whether execution is getting to that point:

  alert ("My message");

Click this button to see what an alert looks like in your system:

There are more sophisticated debugging tools available but they are not within the scope of this course: search the Internet.

Next page | Contents page |