JavaScript: Error - variable already defined? Why?
<p>I'm using the awesome <strong><a href="http://JSLint.com" rel="nofollow">JSLint</a></strong> tool to ensure my JavaScript is "strict". </p>

<p>When I use it however, I get the following errors:</p>

<pre><code>'hexRed', 'hexGreen', 'hexBlue', 'color' are already defined (referring to the "else if" clause)
</code></pre>

<p>My code is below. Any ideas how to fix my code to make it JavaScript "strict"?</p>

<pre><code>function fade(currentStep, numSteps, currentRed, currentGreen, currentBlue, deltaRed, deltaGreen, deltaBlue) {

    if (currentStep &lt; numSteps) {
        var hexRed   = zeroPad(currentRed.toString(16), 2);
        var hexGreen = zeroPad(currentGreen.toString(16), 2);
        var hexBlue  = zeroPad(currentBlue.toString(16), 2);
        var color = "#" + hexRed + hexGreen + hexBlue;

        document.getElementById('abc').style.backgroundColor = color;

        currentRed   += deltaRed;
        currentGreen += deltaGreen;
        currentBlue  += deltaBlue;

        timerID = setTimeout("fade(currentStep, numSteps, currentRed, currentGreen, currentBlue, deltaRed, deltaGreen, deltaBlue)", 70); 

    } else if (currentStep == numSteps) { 

        var hexRed   = endingRed.toString(16);  // &lt;-- JSLint flags this line
        var hexGreen = endingGreen.toString(16);  // &lt;-- JSLint flags this line
        var hexBlue  = endingBlue.toString(16);  // &lt;-- JSLint flags this line
        var color = "#" + hexRed + hexGreen + hexBlue;  // &lt;-- JSLint flags this line

        document.getElementById('abc').style.background = color;
    }
}
</code></pre>
