Learn Create Your Own Split Screen

Next Page

The second useful technique is to break things out into separate functions and give those functions long and descriptive names.
function DoVariousImportantThings() { switch (important) { true: thing() false: otherthing() } } function LoopThroughAllTheThings() { for (var i=0; i<10; i++) { if (a>b) DoAnotherSomething() else DoVariousImportantThings() } // for i } function MySomething () { if ((x=1) || (y-2)) LoopThroughAllTheThings(); }
My long descriptive names are somewhat facetious, but yours should help provide a human-readable narrative that explains what your program is attempting to do.

Not only does it make it easier to read and easier to manage, it also removes the forest of closing curly brackets you might otherwise be faced with.