Link to home
Start Free TrialLog in
Avatar of gdlp2004
gdlp2004

asked on

Comparing Arrays

Hello.
I have been working with this a little while and because I am a little "rusty" with my javascript, I can't figure it out. Here is what I am trying to do, I have to arrays:

testSpecifyList = ('APR','DRE','TAB');
specCompareArray = ('APR','DRE','DRE');

I am trying to compare testSpecifyList and specCompareArray in two different ways. The first being if specCompareArray has any duplicates. (FYI, testSpecifyList will NEVER have duplicates so I don't need to check that.)

The second is, is there a one to one with testSpecifyList to specCompareArray.  Does everything in testSpecifyList match what is in specCompareArray? What would be the best is if you could leave the array with the one that doesn't exists. So, using the example it would look something like this:

     if(testSpecifyList[0]==specCompareArray [0])
           testSpecifyList[0]=null;//not sure if you can do this
           specCompareArray [0]=null;

So at the end of the loop it would display:
testSpecifyList.length=0
specCompareArray.length=1

Any help is greatly appreciated. Thanks in advance!
SOLUTION
Avatar of rama_krishna580
rama_krishna580
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of HonorGod
HonorGod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial