JavaScript Function for picking pairs from a larger set