Skip to content

Instantly share code, notes, and snippets.

@geomago
Last active June 19, 2020 17:18
Show Gist options
  • Select an option

  • Save geomago/a9022e695d49e546506165f9f408916f to your computer and use it in GitHub Desktop.

Select an option

Save geomago/a9022e695d49e546506165f9f408916f to your computer and use it in GitHub Desktop.
remove_dupl_2
let unique = cars.filter ( (item,index) => index === cars.findIndex ( car => car.make === item.make && car.model === item.model) );
// RESULT IS:
[
{id:1,make:"Ferrari",model:"812GTS",price:336000,colour:"rosso corsa"},
{id:2,make:"Ferrari",model:"F8 Spider",price:262000,colour:"giallo modena"},
{id:3,make:"Lamborghini",model:"Aventador S",price:329400,colour:"blu le mans"},
{id:4,make:"Bugatti",model:"Chiron Pur Sport",price:3000000,colour:"blue"},
{id:5,make:"McLaren",model:"New GT",price:203000,colour:"helios orange"}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment