Unsolicited Advice: Write your test suite FIRST

This one trick has saved me countless hours of time and mental anguish: Before writing your program (even if it's just a single function), always write your test suite first. "Test suite" is just a fancy way to say "the code you'll run to show that your program works as expected." 

Por ejemplo: 

// Build a function that takes in an integer and returns its value multiplied by 3. 
var tripler;
// Before you write out your function, think about what you'd expect to see in a variety of cases.
// Test suite for positive, zero and negative inputs:
    // 9
    // 0

Now proceed to write your function:

var tripler = function(int){
    return int*3;

When you're ready to run it, you don't need to waste mental energy coming up with tests because a fresher, earlier version of you already did it for you! Thanks, self!

This might sound silly (especially for the simple example I used), but I can't overstate what a relief it is to offload this burden to the very beginning, when your mind is clear and untrammelled by the many lines of code that Future You is about to write. It also serves as a good organizational strategy to keep you focused on what the actual point of your program is, so you don't wander directionless through Stack Overflow and other such alleyways.