If statement not working, probably something basic gone wrong
<p>I was testing a script and had a problem with a specific part. I isolated the part that was giving me problems.</p>

<pre><code>var target_army = "0";

function test(){
    if (target_army == "0") {
        var target_army = "1";
        alert (target_army);
    } else {
        alert ("nope");
    }
}
</code></pre>

<p>The function runs the alert "nope nope" while target_army should be 0. The part</p>

<pre><code>var target_army = "1";
alert (target_army);
</code></pre>

<p>runs fine but with the addition of the if statement it goes wrong.
Does anyone have an idea where I dun-goofed?</p>