When you are just starting out to learn JavaScript, or any other program that involves writing code, it can become very frustrating. The code doesn't work at all or it isn't doing what you want and you dont have any idea where to go to fix the problem.

Here are a few guidelines to keep the process running as smoothly as possible.


Work out the steps and the logic in your head or on paper before starting

Think about what the structure of the page needs to be and the styling. Think about what each step of the code needs to accomplish. You may well change how you structure your program later, but you need to think it through first so that you aren't spinning your wheels.

What needs to happen first, second, etc. What variables will you need? What jQuery methods will work the best? Where are the loops? Which kind of loops? Are there repeated functions that should be separated so that you aren't wasting code on repeated steps? You get the idea.


Code a little, test, code a little, test

Don't go crazy with writing multiple lines of code, calling functions, loops etc. If there is something wrong with the spelling, syntax or the logic behind the code, it will be that much more difficult to diagnose the problem and fix it.

Write enough code to be able to test if it works. Test it in a browser. Repeat. This way you will know in which section the problem lies. Just do a little bit at a time.


Watch your spelling

Many, many times the code comes to a complete halt because of a simple misspelling. Watch how you spell your variables, watch the case, upper or lower, of the letters. Be sure that commands, methods, functions, are all spelled correctly. Spell checkers won't help here. You need to make a strong effort to spell things correctly the first time around. It will save you many hours of frustration.

With JavaScript, jQuery and other languages, if there is one small error in syntax, the code will likely come to a complete halt.


Watch your syntax

In many cases a JavaScript or jQuery script will come to a complete halt with a single error in the syntax. Close your brackets. Use the correct brackets or symbols. 


Use Error Reporting

Always check the Error Reports with the Error Console of your choice. A good error reporting tool will tell you what is missing and where it is missing. It may take several iterations, fix the error, check again, see a new problem, etc. This will save you a great deal of time to be able to pinpoint simple syntax errors.


Make incremental backups as you go

There will be many times where you will want to go back to the last time the program works. You have made a number of changes to the script and you aren't sure which change broke the code. You may well forget all the changes you made. 

You may want to go back to the last time it works and redo each alteration step by step.

This is why it is important to make incremental backups of the script. Set the backup aside - name it something logical - like intRateProgram-V3.js. Keep the old versions. You can toss them later.


Stay calm

Anxiety can build as your program isn't doing what you want it to. A calm head will help greatly as you debug. Have a logical and methodical way of testing the code bit by bit.