Created
July 26, 2018 15:44
-
-
Save fabianmieller/a9b8e627657acbb6bf9f24bf580cb493 to your computer and use it in GitHub Desktop.
Script to remove duplicates
This file contains 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 length = results.length; | |
let lastStr = ''; | |
let lastID = ''; | |
for (let i = 0; i < results.length; i++) { | |
if (length >= i) { | |
results.forEach((element, index) => { | |
if (lastStr === '') { | |
if (lastID !== index) { | |
lastID = index; | |
lastStr = element[Object.keys(element)[0]]; | |
} | |
} | |
if (lastStr === element[Object.keys(element)[0]] && index !== 0) { | |
results.splice(index, 1); | |
} | |
length = index; | |
}); | |
} | |
lastStr = ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment