Here is a code snippet I am working with:
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;
}
The code operates on the following arrays:
var all_SMS_TO = ["0861932936", "0871355066", "0874132026", "0872908445", "0874132026"];
var all_FORM_NUMBERS = ["", "", "", "", "", "", "0871355066",""];
Its main function is to identify matches and return their indices in the 'all_form_numbers' array.
When I run the code using this setup:
var a = findMatch(all_SMS_TO, all_FORM_NUMBERS);
console.log("Match Found " + a);
I receive the output:
Match Found: 6
This result is accurate. However, when I modify the 'all_form_Numbers' array as follows:
var all_FORM_NUMBERS = ["", "0871355066", "", "", "", "", "0871355066",""];
The resulting output becomes:
Match Found: 1,1
I am seeking assistance to make the output display as:
Match Found 1, 6.
Any help would be greatly appreciated. Thank you.