dimanche 19 avril 2015

Javascript: Find douplicated values from array with keys

Title is pretty much self explanatory...


I want to be able to find duplicated values from JavaScript array.


The array keys can be duplicated so I need to validate only the array values.


Here is an example :



var arr=[
Ibanez: 'JoeSatriani',
Ibanez: 'SteveVai',
Fender: 'YngwieMalmsteen',
Fender: 'EricJohnson',
Gibson: 'EricJohnson',
Takamine: 'SteveVai'
];


In that example:


the key is the guitar brand the value is the guitar player name.


So:


If there is duplicated keys (like: Ibanez or Fender) as on that current example that is OK :-)


But


If there is duplicated values (like: EricJohnson or SteveVai) I'm expecting to get (return) that error:



EricJohnson,SteveVai

Aucun commentaire:

Enregistrer un commentaire