I am trying to compare a string to an array using the following code:
var str = "ML00000";
var arr = ["MC", "CV", "ML", "LV"];
for (var i = 0, len = arr.length; i < len; ++i)
{
if (str.indexOf(arr[i]) != -1)
{
document.write("YES");
}
else
{
document.write("NO");
}
}
It is currently returning "NO NO YES NO" - I would like for the output to be either YES or NO when a match of the string has been found.
Any help on this would be greatly appreciated!
Thank you - Matt