I have the following code.
function findMatch(array_1_small, array2_large) {
var ary = new Array();
for(i = 0;i < array2_large.length; i++)
{
for(z = 0; z < array_1_small.length; z++)
{
if(array2_large[i] == array_1_small[z])
{
var idx = array2_large.indexOf(array2_large[i]);
ary.push(idx);
}
}
}
return ary;
}
That takes the following arrays.
var all_SMS_TO = ["0861932936", "0871355066", "0874132026", "0872908445", "0874132026"];
var all_FORM_NUMBERS = ["", "", "", "", "", "", "0871355066",""];
The sole purpose is to find a match and return the index of the match on the 'all_form_numbers array.
On calling the code
var a = findMatch(all_SMS_TO, all_FORM_NUMBERS);
console.log("Match Found " + a);
I get the following output.
Match Found: 6
Which is correct, however when I alter the all_form_Numbers array to
var all_FORM_NUMBERS = ["", "0871355066", "", "", "", "", "0871355066",""];
I get The following output.
Match Found: 1,1
Could somebody help me with this so it should output;
Match Found 1, 6.
Thanks.