Hello Experts,
I’m trying to looping through array(a) and wanted to check if current element exists in another array (b). if current element is not array (b), then add element array(b). but I’m not getting correct results.
[code=html]
fArray1 = this is query and getting following results ([cn=user1,ou=orga,ou=orgb,o=org, cn=user2,ou=orga,ou=orgb,o=org, cn=user3,ou=orga,ou=orgb,o=org,]}
for (i = 0; i < fArray1.size(); i++)
{
if (fArray1)
{
var chkarray1 = finalArray.toString(); /*finalarray has ([cn=user2,ou=orga,ou=orgb,o=org, cn=user3,ou=orga,ou=orgb,o=org, cn=user4,ou=orga,ou=orgb,o=org, cn=user5,ou=orga,ou=orgb,o=org]]} */
var testarry1 = fArray1.get(i).toString();
if (fArray1.get(i).toString()=== ‘chkarray1’) /* tried this but did not work */
// if (chkarray1.indexOf(fArray1.get[i]) != -1) /* tried this but did not work */
{
trace out
}
else
{
finalArray.add(testarry1.get(i));
}
}
}
finalarray should have [cn=user1,ou=orga,ou=orgb,o=org, cn=user2,ou=orga,ou=orgb,o=org, cn=user3,ou=orga,ou=orgb,o=org, cn=user4,ou=orga,ou=orgb,o=org, cn=user5,ou=orga,ou=orgb,o=org].
please advise.