title: Comparing Arrays with nested loops
body: <p>I am trying to compare values of two arrays against each other. If a match is found - do something - else do this. </p>
  
  <p>I put together a fiddle with my code at <a href="http://jsfiddle.net/ZvmHx/1/" rel="nofollow">http://jsfiddle.net/ZvmHx/1/</a></p>
  
  <p>If you uncomment the second the alert on line 14 you'll see what is wrong. I can't seem to prevent the second alert from firing.</p>
  
  <p>Thanks!</p>
  
  <pre><code>var getkeywords = ["John","Frank","Sarah"]; 
  var captionarray = ["Jim","Joe","Lee","Steve","John","Michelle","Brad"];    
  
  for (k = 0; k &lt; getkeywords.length; k++) {
      for (l = 0; l &lt; captionarray.length; l++) {
  
      if(getkeywords[k] == captionarray[l]){
  
          alert('Found &gt; ' + getkeywords[k] + ':filter image');
  
      }else{
  
          //alert('not found &gt; ' + getkeywords[k] + ':filter image');
  
      }
    }
  }
  </code></pre>