I don't know why is this happening but there's something wrong with indexOf when using array of arrays because it returns true even when the words partially match the word, here's an example
arr = [['abc'],['ABC']];
arr[0][0].indexOf('abc'); //returns 0
arr[0][0].indexOf('ab') //returns 0
arr[0][0].indexOf('a') //returns 0
arr[0][0].indexOf('abcd') //returns -1
arr[0][0].indexOf('ABC') //returns -1
// Simple array indexOf
arr = ['abc'];
arr.indexOf('a'); // returns -1
I'm not sure if this is an issue or it's just me not knowing how to use it.
I was thinking, I don't know if I'm asking the question in the wrong place, maybe I need to go to some JavaScript discuss or something.
This seems like a basic javascript question, try posting it on stackoverflow
Thanks guys!
@martiuh arr[0][0] is the string 'abc', so you actually call the String indexOf method.
I just realize this was a stupid question and I feel a bit ashamed, thank to @vsemozhetbyt and @addaleax for the help and the solution was to call arr[0].indexOf(abc) and it worked the way I wanted to..