Javascript Arrays & Loops
<p>I'm working on a mock censorship google for history class. What is supposed to happen is a user enters a term, and the script will check for whether it is a "blocked" term or a searchable term. If the term is blocked, it will lead to a different page, and if it's searchable, it will lead to the actual page. However, with my code, the script is not picking up the blocked term. Any ideas?</p>

<p>Javascript:</p>

<pre><code>function searchCensor() 
{
    var keyTerms = document.getElementById("search").value; 
    var blockedTerms = new Array("censorship", "democracy");
    var counter, blocked;
    for(counter = 0; counter &lt; blockedTerms.length; counter++) {
        if(keyTerms == blockedTerms[counter])
            blocked = 1;
        else
            blocked = 0;   
}
    switch(blocked)
    {
    case 1: window.location = "http://andrewgu12.kodingen.com/history/censor.php";
    case 0: window.location = "https://www.google.com/search?q="+keyTerms;
    }   
}
</code></pre>

<p>website: <a href="http://andrewgu12.kodingen.com/history/" rel="nofollow">http://andrewgu12.kodingen.com/history/</a></p>

<p>Thanks!</p>
