Skip to content
Advertisement

Tag: higher-order-functions

How can I extract from an array of arrays all the arrays that have the same value in their first field?

The following function elegantly finds duplicates in 1-dimensional arrays: When I send it (for example) this array [‘123456’, ‘787877’, ‘763223’, ‘787877’, ‘854544’] it returns [‘787877’]. What I need is something similar that works for a 2-d array so (for instance) inputting returns [[‘787877’, ‘Jones’], [‘787877’, ‘Quagmire’]] (To be clear, I’m only interested in whether the 1st field of each sub-array

Advertisement