Created
June 19, 2020 11:43
-
-
Save geomago/93ffc34476f06c2f4de88a269aae2913 to your computer and use it in GitHub Desktop.
merge_arrays_1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let allCars = cars.concat(cars2); | |
let unique = allCars.filter ( (item,index) => index === allCars.findIndex ( car => car.id === item.id) ); | |
// 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"}, | |
{id:6,make:"Ferrari",model:"F8 Spider",price:262000,colour:"giallo modena"}, | |
{id:7,make:"Ferrari",model:"F8 Spider",price:262000,colour:"red"}, | |
{id:8,make:"Bugatti",model:"Chiron Pur Sport",price:3000000,colour:"red"}, | |
{id:9,make:"Lamborghini",model:"Huracan",price:206790,colour:"green"}, | |
{id:10,make:"Bugatti",model:"Chiron Sport 110 ans",price:16000000,colour:"dark gray"} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment