I am trying to compare values of two arrays against each other. If a match is found - do something - else do this.
I put together a fiddle with my code at http://jsfiddle.net/ZvmHx/1/
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.
Thanks!
var getkeywords = ["John","Frank","Sarah"];
var captionarray = ["Jim","Joe","Lee","Steve","John","Michelle","Brad"];
for (k = 0; k < getkeywords.length; k++) {
for (l = 0; l < captionarray.length; l++) {
if(getkeywords[k] == captionarray[l]){
alert('Found > ' + getkeywords[k] + ':filter image');
}else{
//alert('not found > ' + getkeywords[k] + ':filter image');
}
}
}