2 Replies Latest reply on Apr 13, 2016 2:29 PM by pav55

    get indexes of the same array values

    pav55 Level 1

      Hi guys,

      I'm trying to get indexes of array items with the same value but can solve it on my own.

      my case is:

      array1 = [1,2,3,4]; <-- these are pages names, always in asc order (these array I'm using only to check results of my work, probably will be not useful for you but maybe..)

      array2 = [1,1,2,2,2,3,4,4,4]; <--these numbers are random but always in asc order (these are pages names for array 3 items)

      array3 = [a,b,g,i,f,e,c,h,d]; <--these are all values of items I want to work with later. amount of items is always the same as in array2 and theirs indexes are corresponding.

      array4 = [];


      I need to remove from array3 all items but one of each number from array2 (like i will remove duplicates) or push to array4 one item of array3 for each number from array2 (like I will ignore duplicates)

      don't know is my desc is clear enough but the result I need to get is:


      ex. [a,g,e,c]

      above example shows items from array3 for every number of array2 but it dont have to be first one, can be second or third etc if exist, but have to be only one.


      I thought if I'll get indexes of duplicated values from array2 and remove this indexes in array3 will get what I want but cant solve it.

      Will appreciate any help.