Created
January 29, 2019 00:54
-
-
Save mohshbool/669c6b9037a9fa5f7e142fc3dea4eb6c to your computer and use it in GitHub Desktop.
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
// https://codeburst.io/javascript-array-distinct-5edc93501dc4 | |
export const uniqueArray = (array) => { | |
console.log(array) | |
const result = [] | |
const map = new Map() | |
for (const item of array) { | |
if(!map.has(item.imdbID)){ | |
map.set(item.imdbID, true) | |
result.push({ | |
imdbID: item.imdbID, | |
Title: item.Title, | |
Year: item.Year, | |
Poster: item.Poster | |
}); | |
} | |
} | |
console.log(result) | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment