i have an arrayX of three elements , and i’m using $.inArray() to search for this three element in another arrayY … and returning the location for each X element in Y
X = [1,2,3] ;
y = [1,5,6,1,6,9,3,2] ;
But there is duplication in y, 1 occurred twice in y[0] and y[3]
The real example is here http://jsfiddle.net/minagabriel/kHG9K/
How do I get the first 1 occupancy and skip the others?
I’m pushing the location of 1,2,3 in an array with the first occurred of each one
http://jsfiddle.net/kHG9K/18/
I just remove the item from the array once it has been found.
NOTE: That’s not the right way to loop through an array. Use
for(index;index<length;index++)to avoid quirks.