If I have an array like this:
arr = ["hey", "some", "string", "aaa", "ccc"];
And I want to compare if there is same string in array but with a special rule like this:
if arr[1] == "some"
arr = ["hey", "bbb", "string", "aaa", "ccc"]; //return true
arr = ["hey", "some", "string", "aaa", "bbb"]; //return true
arr = ["hey", "some", "string", "aaa", "some"]; //return false
I've already know how to compare string with this code:
var arr = ["hey", "some", "string", "aaa", "ccc"];
var val = $('#somethingFromTableForm').val();
for(var i = 0; i < arr.length; i++) {
if (arr[i].indexOf(val) > -1){
alert("same string");
return false;
}
}
return true;
But how to compare string with this special rule?